I have created a console app referencing http://www.antlr.org/download/CSharp
using System;
using Antlr.StringTemplate;
using Antlr.StringTemplate.Language;
That I want to compile by command line with
csc /r:c\antlr\antlr.ru开发者_开发技巧ntime.dll;c\antlr\StringTemplate.dll myprog.cs
It created the exe but when executing it says it cannot find StringTemplate or dependencies why ? I have all dll package in same directory.
Update: the same program build under visual studio works but I need to do this by command line.
Update 2: even copied to exe path it still can't find them weird !
Update 3: ok finally works I confused visual studio bin output and my csc output dir.
That's because you are not using the friendly IDE that takes care of these details for you. Since you're doing this by hand, it is up to you to copy the DLLs yourself.
csc /r:c\antlr\antlr.runtime.dll;c\antlr\StringTemplate.dll myprog.cs
copy c:\antlr\antlr.runtime.dll .
copy c:\antlr\stringtemplate.dll .
The DLLs are now in the EXE's 'probing path', it won't have any trouble finding them.
The dlls have to be in the same directory of the exe unless they are in the GAC.
DLLs are search for on the PATH env variable.
Unless you specially put ;.; in your path, CWD is not searched.
Could be a number of things. For me, the most common cause of an error like this -- assuming that all the DLLs are indeed where they should be (next to the running executable) -- is that your application is compiling as Any CPU, but you are running it on a x64 machine (so the CLR loads it as x64) but one of the assemblies you reference has to interop to native code or otherwise makes a reference to a x86 (32-but) unmanaged DLL. Since you can't load a 32-bit DLL into a 64-bit process, the assembly load fails.
精彩评论