You will get the SEHException if you attempt to access RoleEnvironment if you're not running in the dev fabric or Azure fabric. I believe you're inadvertently running your website under the asp.net development server, meaning you're not in the dev fabric (I've confirmed that this will throw an SEHException). In other words, you've either set your website project as the startup project, or you've right-clicked it and told it to run.
You must set the cloud project itself as the startup project, which will then show your website running on port 81 by default. The cloud project is the project that has, as its members, all of your role definitions. You can look at your browser's URL bar and easily tell if you're running in the asp.net dev server, because you'll be on some random port number instead of port 81.
You should make sure you're running in the dev fabric or Azure fabric by checking RoleEnvironment.IsAvailable
. If that's true, you're safe to call anything in RoleEnvironment. If it's false, you're not running within the fabric.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…