Situation:
- I merged 2 assemblies: Functionality.dll and Models.dll
- Functionality calls:
RazorEngine.Razor.Parse("template", new Models.Model())
(simplified) (Functionality.dll references Models.dll and RazorEngine. RazorEngine is added to the GAC. Merged Assembly not for various reasons) - Merged assembly is uploaded into 3th party tool. This 3th party tool loads this merged dll dynamically into its appdomain and executes it.
Result: Exception is thrown:
Unable to compile template. The type or namespace name 'Models' could not be found. (are you missing an assembly reference?)
To me this is weird, because the 'Models' namespace is part of the merged assembly. And if I check (with the debugger) it is loaded. (AppDomain.CurrentDomain.GetAssemblies).
BUT: the merged assembly has no location. (Assembly.Location = ""). I assume this is because it was dynamically loaded by the 3th party application? And that causes the RazorEngine to throw this exception, because it adds references to all loaded assemblies by location (@params.ReferencedAssemblies.Add(locationofdll)
)'
My question is:
How can I make sure that my dynamically loaded, merged dll is (correctly) loaded into the appdomain so the RazorEngine can add a reference to it? For me it's not handy to ALSO put my merged dll into the GAC. (I already uploaded it into my 3th party application). And that 3th party application has potentially multiple servers. I know, it is possible to add it in the GAC, and maybe that's what the GAC is for, but I was just wondering if I could somehow load my merged assembly (again?) into the currently running AppDomain (With a location?) so the RazorEngine can add a reference to it. (Weird right? The RazorEngine.dll runs in the same AppDomain as the merged dll. I doublechecked that)
Long question. Sorry for that. I hope someone can give me some pointers on how this all hangs together (AppDomain, dynamically loaded, merged assemblies using a GAC assembly (RazorEngine) that needs to know the Types in the merged assembly.... pfft)
Thanks!
fuslogvw
? – leppie