UserControl won’t load in web page when assembly has a strong name and uses Visual Basic

This is how I spent the last 4 hours:

Create a Visual Basic.NET user control following the approach in this article, although it clearly has been translated from Visual C# without testing.

Fix the code and watch it in all it’s beauty. Note, you have to run it from a browser, file paths are not supported.

The problem is, to call into COM objects, I need UnmanagedCode permission. This creates a cascade of further requirements.

Sign the assembly with a strong name.
Create a code group to grant Unrestricted permission.

However, as soon as I sign the assembly, the control won’t load, no matter what.

Unsigned – loads. Signed – won’t load.

I went through the same excercise with C# and everything was smooth.

Not that I’m a fan of VB at all, but let’s say the code base in
question is complicated enough (late bound calls etc.) to justify the use of it.

With the debugger, I found a couple of SecurityExceptions thrown, and one complaint about not allowing partially trusted callers, so I suspect the culprit is either the VisualBasic assembly or one of the WinFX assemblies that somehow magically get loaded.

This entry was posted in Coding Horror. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s