积极答复者
动态编译引用程序集路径问题........

问题
-
System.CodeDom.Compiler.ICodeCompiler comp = provider.CreateCompiler();
System.CodeDom.Compiler.CompilerParameters cp = new System.CodeDom.Compiler.CompilerParameters();
cp.ReferencedAssemblies.Add("system.dll") ;
cp.ReferencedAssemblies.Add("自己的动态库.dll") ;//试问这些动态库的位置 是应该和可执行程序放在一起? 放在一起编译代码是没有任何问题.
cp.GenerateExecutable = false ;
cp.GenerateInMemory = true
但是现在的问题是:在系统中有个按钮要打开浏览文件(也就是openFileDialog),当选择了一个文件之后,它就会去按照选择的这个路径去找“自己的动态库.dll"”
这个动态库;这个位置肯定没有呀;它怎么会改变系统的执行文件路径呢,真是不知道怎么解决了, 急切期待朋友们给予指点....
efforts..
答案
-
Hi Efforts.... _,
欢迎来到MSDN中文论坛。
这边有各种方法去获得指定的路径。
http://www.360doc.com/content/11/0425/19/6832513_112262634.shtml
我觉得你这边可以用Assembly.GetExecutingAssembly().Location去实现。
Jason Wang [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jason Dot WangModerator 2013年6月6日 9:23
-
你这样加载的是相对路径的,你可以指定绝对路径去加载你的Dll了,通过这个代码Environment.CurrentDirectory来获得当前活动目录的绝对路径
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. my sample
- 已建议为答案 Learning hard 2013年6月5日 10:51
- 已标记为答案 Jason Dot WangModerator 2013年6月6日 9:23
全部回复
-
Hi Efforts.... _,
欢迎来到MSDN中文论坛。
这边有各种方法去获得指定的路径。
http://www.360doc.com/content/11/0425/19/6832513_112262634.shtml
我觉得你这边可以用Assembly.GetExecutingAssembly().Location去实现。
Jason Wang [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jason Dot WangModerator 2013年6月6日 9:23
-
你这样加载的是相对路径的,你可以指定绝对路径去加载你的Dll了,通过这个代码Environment.CurrentDirectory来获得当前活动目录的绝对路径
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. my sample
- 已建议为答案 Learning hard 2013年6月5日 10:51
- 已标记为答案 Jason Dot WangModerator 2013年6月6日 9:23