Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

C#: How to embed DLL into resourcefile (no dll copy in program directory) -


i have c# application (project a) requires x.dll. have added project produces x.dll reference in visual studio. have added release build of x.dll resource file in binary. have told project not copy x.dll output directory.

now want a.exe load, "hey can't find file", in resource file , use assembly.load(byte[]) x.dll back. have code re-magicifies dll back, code never called.

currently have bone simple project, trying work. compile ok. when run it, filenotfoundexception on x.dll.

i have:

[stathread] static void main() {     appdomain.currentdomain.assemblyresolve += new resolveeventhandler(currentdomain_assemblyresolve); } 

but breakpoint in *currentdomain_assemblyresolve* never gets hit. filenotfoundexception immediately. surely there missing?

this question seems similar trying achieve, , worked asker.

merge .dll c# assembly?

are doing differently? specifically, if you're targetting older version of .net framework, maybe that's hint understanding why application behaving differently.

another direction, use tool such fusion log viewer analyze going on when tried load assembly. may give more hints. if manage log information, posting in question may figure out.

edit: explanation, following comment.

well, think know problem is.

in main method, refering type in other dll. doing in static code, i.e. use type explicitly in code (as opposed loading dynamically name).

why problem? clr tries load assembly in order jit main itself.

your filenotfoundexception thrown while main being compiled. main didn't start running, , therefore event handler wasn't registered.

a simple way check if i'm right change code this:

static public void main(string[] args) {     appdomain.currentdomain.assemblyresolve += myeventhandler;     mymain(); }  // clr try load assembly before starting execution // of method. needs assembly in order jit method because has  // know thing type. static public void mymain() {     using(var thing = new thing())     {          // ...     } } 

the important difference main has no dependency on assembly, there no problem jit , run it.

by time mymain being jit'ed, event handler in place can manually load assembly.

by way, avoid possible similar pitfall, make sure class in main defined doesn't have field type other assembly, because in case also, clr try loading assembly before main starts, in order compile it.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -