Putting Cobra.Lang.dll in the GAC
Posted: Thu Oct 16, 2008 4:52 am
GAC = Global Assembly Cache. It's essentially the system wide storage for shared .dll's. The idea here is to get Cobra.Lang.dll put in there and then change the -embed-run-time option to default to "false" thereby speeding up compilation.
Here's what I did:
* Reviewed http://support.microsoft.com/kb/815808
* Brought up the command line prompt for the VS 2005 tools.
* Created a key with this command:
sn -k CobraGAC.snk
* Added this to CobraLang.cobra: but then got a warning that I should use a command line option instead of an assembly attribute to sign an assembly. So I removed it, and did this:
cobra -bsl -v -key-file:CobraGAC.snk
* And installed the resulting DLL to the GAC with:
gacutil -I Cobra.Lang.dll
* And verified it was there by listing it with:
gacutil /l Cobra.Lang
* I then deleted the Cobra.Lang.dll in the current directory and tried it out:
cobra -ert:no -c hello
* But it doesn't work:
error: Metadata file "Cobra.Lang.dll" could not be found
* I tried again with verbosity cranked up:
cobra -ert:no -v:2 -c hello
Apparently, Cobra is able to locate and read the DLL and to generate code. It's the C# compilation that generates the error message.
* Reissuing with the C# compilation line gives the error message again. Axing the ".dll" of the "/r:Cobra.Lang.dll" gives the error message as well.
* I tried bypassing the CSharpCodeProvider, just to try something different, with:
cobra -ert:no -v:2 -sharp-compiler:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" -c hello
but got the same error message.
This was all done in a clean workspace.
So Cobra can seemingly locate the DLL from the GAC and read its contents. But C# compilation of the generated code chokes trying to read it regardless of whether we go through the code provider or invoke the compiler as an external command.
Any ideas?
-Chuck
Here's what I did:
* Reviewed http://support.microsoft.com/kb/815808
* Brought up the command line prompt for the VS 2005 tools.
* Created a key with this command:
sn -k CobraGAC.snk
* Added this to CobraLang.cobra:
assembly
has AssemblyKeyFile(r'C:\Documents and Settings\Chuck\...\SourceCobraGAC.snk')
cobra -bsl -v -key-file:CobraGAC.snk
* And installed the resulting DLL to the GAC with:
gacutil -I Cobra.Lang.dll
* And verified it was there by listing it with:
gacutil /l Cobra.Lang
* I then deleted the Cobra.Lang.dll in the current directory and tried it out:
cobra -ert:no -c hello
* But it doesn't work:
error: Metadata file "Cobra.Lang.dll" could not be found
* I tried again with verbosity cranked up:
cobra -ert:no -v:2 -c hello
Apparently, Cobra is able to locate and read the DLL and to generate code. It's the C# compilation that generates the error message.
* Reissuing with the C# compilation line gives the error message again. Axing the ".dll" of the "/r:Cobra.Lang.dll" gives the error message as well.
* I tried bypassing the CSharpCodeProvider, just to try something different, with:
cobra -ert:no -v:2 -sharp-compiler:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" -c hello
but got the same error message.
This was all done in a clean workspace.
So Cobra can seemingly locate the DLL from the GAC and read its contents. But C# compilation of the generated code chokes trying to read it regardless of whether we go through the code provider or invoke the compiler as an external command.
Any ideas?
-Chuck