0
votes

I get this when trying to open a winforms form.

  1. Could not find type 'MyCompany.MyControls.MyControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

  2. The variable 'NavigationControl' is either undeclared or was never assigned.

The assembly is signed, using "Delay sign only", since I include a manifest with mt.exe in a post-build event. Here I also re-sign the assembly with sn.exe:

sn.exe -R "$(TargetPath)" "$(ProjectDir)key.snk"

If I disable signing of the assembly altogether, it works.

Is there any other way to do this? I assume VS2010 is looking for the DLL using the wrong strong name or something...

1

1 Answers

0
votes

Your assembly is delay signed. That means, it has a signature, but that signature is not valid (only later when built by the buildserver with the real key). So on your developer machine, the signature is invalid and your assembly is not loaded.

There's two options:

1) You don't sign on the developer machines at all. Only sign on the build server.

OR

2) Make sure your developer machine takes your delay sign key as valid, although it's not.

You can register keys that will validate, no matter what. For obvious reasons, this is DEV MACHINE ONLY! Do not use on production machines or your whole signing concept will go south.

You need to check the path to sn.exe on your machine it might differ:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe" -Vr *,YOURKEYHERE

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\sn.exe" -Vr *,YOURKEYHERE

You need to run those commands as Administrator and reboot.

YOURKEYHERE is the public key token of your assembly, the part after PublicKeyToken= when you do this:

Console.WriteLine(typeof(ATYPEOFYOURASSEMBLY).AssemblyQualifiedName);