CompilerOptions.
-
31 มกราคม 2550 16:51
I am trying to use the C# CodeCom provider and in particular I find two options, one that specifies the "ReferencedAssemblies" and one that specifies the compiler options ("CompilerOptions"). If I specified the full path to some of the .NET 3.0 assemblies like:
cp.ReferencedAssemblies.Add(
"System.dll");cp.ReferencedAssemblies.Add(@
"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll");This works. If I don't specify the path then I get errors indicting ServiceModel.dll could not be found. Rather than specifying the full path to all of the .NET 3.0 assemblies I would like to let the compiler know where else it can search for assemlies. I have chosen:
cp.CompilerOptions = string.Format("/lib:{0}", @"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0");
I still get erros that the assembly cannot be found and I look at some of the temporary files (specifically the .cmdline) file and I find that the /lib option is not there. It seems that the "CompilerOptions" are being ignored. Is there something I am missing so I can pick up an additional assembly search path?
Thank you.
Kevin
ตอบทั้งหมด
-
31 มกราคม 2550 17:19ผู้ดูแลTry adding an extra space before "/lib" (making it " /lib"), it is the last argument passed to the compiler but the framework adds a trailing space, not a leading space. Also try referencing the assembly by its display name so the compiler finds it in the GAC. For example: "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
-
31 มกราคม 2550 17:29
I tried adding the space and I still get:
error CS0006: Metadata file 'System.ServiceModel.dll' could not be found
error CS0006: Metadata file 'System.Runtime.Serialization.dll' could not be fo
undI don't know the details of the .NET 3.0 assemblies (PublicKeyToken, etc.) at this time so I have not tried that yet. I still have:
cp.CompilerOptions =
string.Format(" /lib:{0}", @"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0");cp.ReferencedAssemblies.Add(
"System.dll");cp.ReferencedAssemblies.Add(
"System.ServiceModel.dll");cp.ReferencedAssemblies.Add(
"System.Runtime.Serialization.dll");Kevin
-
31 มกราคม 2550 17:33
Looking at the command line temporary file it looks like even with the space the CompilerOptions are getting ignored:
/t:library /utf8output /R:"System.dll" /R:"System.ServiceModel.dll" /R:"System.Runtime.Serialization.dll" /out:"wsDataContract.dll" /D:DEBUG /debug+ /optimize- /w:3 /optimize "wsDataContract.cs"
Kevin
-
11 กรกฎาคม 2551 19:27If I have a third party dll that is GAC'ed, specifying it's full assembly name still generates a CS0006 exception.
-
30 กรกฎาคม 2551 13:05
This works:
par.CompilerOptions =
string.Format(@" /lib:{0}", "\"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\v3.0\"");
You'll have to enclose the path with double quotes "", because the options are commandline options. Without the double quotes the argument is splitted up in three parts:
c:\Program , Files\Reference and Assemblies\Microsoft\Framework\v3.0
Hope this is helps for anyone who is looking at this thread.
Peter -
21 สิงหาคม 2555 23:02
Worked for me, and within a sharepoint workflow no less.
Thanks!