473,218 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

Compile code at runtime & Add Reference & FileNotFoundException

I have a text file which contains VB.NET code. The VB.NET code is actually a
Class that can contain code, which simply displays a message box or does
something more complicated (i.e Excel/Word Automation, communicate with the
DB and/or WebServices, talk to other classes). To achieve a complicated task,
this class would need reference to other custom assemblies (not part of .net
framework) that are possibly not installed to the GAC.

In my application, I use the System.CodeDom.Compiler.ICodeCompiler's
CompileAssemblyFromSource method to compile the text file code into an
assembly. Before the new assembly is created, I use the
ReferencedAssemblies.Add method to add reference to all the DLL files needed
by it. The ReferencedAssemblies.Add method is given the full path to a DLL
file, but the full path is a directory other than the main application's App
Direcotry(=where the Main.Exe is run from). For assemblies that are in the
GAC (such as System.dll and System.Windows.Forms.dll) this works fine; the
text file source code compiles without errors and I can call its methods,
etc. When adding reference, a full path is also specified for custom dll
files, but I get an FileNotFoundException. If I place the Custom Dll files
int the App Directory I do not get an exception and the source code compiles,
but this is not a feasible option.

I've tried setting the CompilerOptions parameter to the full path from
above, but that directory is not even probed. The property is set as follows:
cpCompilerParameters.CompilerOptions = "/lib:D:\Reports\CustomFiles\". Is
this the correct way of doing it?

Are there any other mechanisms by which I can tell the Main application
where to probe for these custom dlls?

Thanks for your help.
Jul 21 '05 #1
1 2907

I'm also using the CodeDOM namespace and perform runtime compilations.
I ran into this exact same problem, only my DLLs were placed in the
same folder as the executable, but it still failed. What I did was to
get the full path of the executing assembly and concatenate it to the
dll name. This solved the problem.

I know that you've written that this is not an option (placing the DLLs
in the same folder as the executable), but I've listed it anyway to
share with you the information that at least a full path is supposed to
work (worked for me...).

BTW: I have not set the compiler options at all in order to achieve
this effect, as you demonstrated.

I'd check the Compiler Errors collection, if you haven't already done
so. Maybe you'll find somehow the actual path it _is_ looking for, and
then you'll figure out what your problem is.

One more thing - is it possible that you're placing the DLLs on a
mapped network drive or something like that ? Did you try placing the
DLLs in an actual local hard drive directory ?

Another advice - you mentioned that if the DLLs are placed in the
executable's folder, it compiles ok. Try placing it there, but specify
the full path name anyway - is it still working ?

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: John Doe | last post by:
Hello, I'm currently working on a little tool that would benefit from having a little embedded script language. Although I have C++ source code available for such a script language, I have 2...
by: Lowell | last post by:
Any tips for trouble shooting errors when the ASPX page won't even compile? What happens is that VS will "build" the code-behind object and the component that it instantiates, but when I navigate to...
by: Brad | last post by:
After compiling my asp.net project I'm receiving a "BC31011 - Access is denied" error when attempting to run or debug. The only thing that seems to resolve problem is IISReset. After a reset my...
by: normd | last post by:
I have a text file which contains VB.NET code. The VB.NET code is actually a Class that can contain code, which simply displays a message box or does something more complicated (i.e Excel/Word...
by: Lonewolf | last post by:
hi all, I realize the example on MSDN for IPCChannel has compile error in VS2005 pro. Either I'm missing something or there's something seriously wrong with MSDN on that section. I reproduce the...
by: wei8010 | last post by:
int fun() { static int x = 1000; return 0; } int main( int argc, char* argv ) { cout<<x<<endl; }
by: desktop | last post by:
I have read that using templates makes types know at compile time and using inheritance the types are first decided at runtime. The use of pointers and casts also indicates that the types will...
by: Jennifer | last post by:
I've been working with an Access 97 application, through various versions, for 10 years. This application runs asan mde in runtime mode on hundreds of PCs around the globe. About a week ago I...
by: Verde | last post by:
I would appreciate your comments on the following two alternatives of a given method. This isn't a real method, as I'm not concerned about the "real work" it could be doing, but would like to...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.