Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Strongly named assembly Problem .Net

  Asked By: Mathew    Date: Jun 17    Category: Sharepoint    Views: 1240

I have taken two precompiled assemblies and strongly named them. One was one I created, the other is a 3rd party assembly (the Microsoft Data Application Block). The one I created uses the MSAB assembly. When they were developed originally (for non-SharePoint uses), they didn’t need strong names. However now I need to use my assembly in a web part I’m building. So I had to go back and strongly name the two… but I don’t have the source code to them to add the key in the AssemblyInfo.cs file as part of the build process.

So I used the method described in the .NET SDK: I got the MSIL of both assembiles and used that to bind the key to them:

Ildasm assembly.dll /out:assembly.il

Ilasm assembly.il /dll /key=keypair001.snk (after renaming the original.

However, when I try to run my web part, my assembly works just fine… but the MSAB one doesn’t… the Framework says it’s not strongly named.

Just to be sure, I used both the SN.EXE and SECUTIL.EXE tools to see the public key and public key blob for both… they have the same values (expected as I used the same key pair file on both). I am also able to drop them in the GAC successfully… to me this means they have strongly named assemblies.

So I’m at a loss. Everything I do makes me think they are strongly named, but .NET keeps saying they aren’t. Any ideas? Any chance when my assembly was built, it would only work with the non-strongly named MSAB assembly?



6 Answers Found

Answer #1    Answered By: Robert Wilson     Answered On: Jun 17

Can you drop  the MSAB assembly  into the GAC? I think that only strongly
named assemblies  can be put into the GAC so that may be a good
independent test. Outside of that, no other tests come to mind.

Answer #2    Answered By: Chase Wagner     Answered On: Jun 17

I can drop  it (my signed version) into the GAC and see it’s  public key  just fine. Still get the error… very odd.

Anyone know how you’d make sure  the .NET Framework is touching the correct assembly? I can’t find any other references out there, but thought it would be worth a try.

Answer #3    Answered By: Terrance Vasquez     Answered On: Jun 17

I don't know if this will help but I hit a similar problem  when I wanted to use a dll  within a webpart. An Interop DLL was built  automatically by the system but I couldn't strong-name that Interop DLL.

The steps I used in the end are these:

tlbimp hmstocks.dll /out:interop.hmstocks.dll /keyfile:keypair.snk /primary
regasm hmstocks.dll

Hope you can make some use of that.

Answer #4    Answered By: Darrin Massey     Answered On: Jun 17

I'm outside of my realm of expertise here but interested in the

Answer #5    Answered By: Jeffrey King     Answered On: Jun 17

Thanks for the post… unfortunately that will put me in the same position as I’m in now.

You’re basically taking a dll  and strongly naming it… same thing I did, but .NET doesn’t see it as having a strong name at runtime, although all the utilities (SN, SECUTIL) and installing it into the GAC, show that .NET thinks it’s  strongly named.

Answer #6    Answered By: Kendrick Townsend     Answered On: Jun 17

I’ll keep you informed. I didn’t solve the issue, but I got around it for the time being. Since the assembly  in question is an MSAB (the data  one), I downloaded the latest version from MSDN, looked at the source, saw it contained a single class (in a single code  file), so I just included that code file  into my custom assembly. Then I signed my assembly (using an SNK file and the common AssemblyInfo.cs entries) and added the “AllowPartialTrustCallers” assembly attribute so my assembly could be used in unsigned applications as well as those that require specific CAS settings (such as SharePoint).

So… I’m no longer held up, but didn’t solve the issue (just got lucky I still had access to the source). No hits on my posts on the SharePoint or .NET security newsgroups. I’ve ping’d two CAS experts (common SharePoint bloggers) to see if they have ideas  and my internal MS resources. I’ll post results.

Didn't find what you were looking for? Find more on Strongly named assembly Problem .Net Or get search suggestion and latest updates.