Archived Thread: 'Assembly not found exception when running custom templates'
-
Assembly not found exception when running custom templatesPosted by subdigital on Wednesday, July 18, 2007
I'm trying to customize the generation of my classes to suit my project. Specifically I have done 2 things:
- added a switch to sonic.exe called "/segregateBySchema 1" that will output all generated classes and controllers to a schema folder underneath the output directory. (for example, generated\output\dbo\SomeClass.cs )
- customized the template for the classes and controllers to append the correct schema as a namespace
(for example, MyProject.Entities.dbo)
I have the first part working fine. I modified the SubSonicCommander project to add this.
When I try to load the templates I get a weird error message on the compile step (of sonic.exe). Here is the error:
Finished Running Compiler... ERROR: Trying to execute generate Error Message: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Documents and Settings\00916034\Local Settings\Temp\a4bujh9w.dll' or one of its dependencies. The system cannot find the file specified. File name: 'file:///C:\Documents and Settings\00916034\Local Settings\Temp\a4bujh9w.dll' at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() at SubSonic.CodeGenerator.TurboCompiler.Run() in C:\sandbox\subsonic\SubSonic\CodeGeneration\CompileEngine.cs:line 101 at SubCommander.Program.Main(String[] args) in C:\sandbox\subsonic\SubCommander\Program.cs:line 94 WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. Execution Time: 1118ms ***************** COMPLETED *******************
I only had a few small changes to the templates, but I figured I would eliminate possibilities, so I copied the template directly from the templates folder (with no modification). I still get the error.
This step works fine if I omit the templateDirectory setting and just use the built-in templates.
Ideas?
-
Re: Assembly not found exception when running custom templatesPosted by woeliewoelie on Wednesday, July 18, 2007
Same error here when generating stored procedurs and view with the subsonic tools for visual studio. When I remove the template directory it work's fine.
-
Re: Assembly not found exception when running custom templatesPosted by canofunk on Thursday, July 19, 2007
I hate to ask this, but are you 100% positive that the path to the templates is correct?
You might also want to try setting some breakpoints in GetTemplateText() of CodeService.cs, which should help narrow down the issue...
-
Re: Assembly not found exception when running custom templatesPosted by woeliewoelie on Thursday, July 19, 2007
The path to my template directory is correct because I use these templates for generating my classes and controllers. But when I want to create the stored procedures class I get the above error.
-
Re: Assembly not found exception when running custom templatesPosted by canofunk on Thursday, July 19, 2007
Just to be clear, you receive this error when you point to the path for the templates that was installed with 2.0.3, even if no changes have been made to the template file?
-
Re: Assembly not found exception when running custom templatesPosted by woeliewoelie on Thursday, July 19, 2007
Yes, that's true. My stored procedures template isn't modified and is the same as the template installed with 2.0.3. My current workaround is to remove the templateDirectory tag when I want to regenerate my stored procedures class (then the template dir from my installdirectory is used) and put it back when I am regenerating my controllers and business objects (then my custom templates are used).
-
Re: Assembly not found exception when running custom templatesPosted by canofunk on Thursday, July 19, 2007
SubSonic Tools is separate project that is outside our codebase. Do you have the same problem if you use SubCommander?
-
Re: Assembly not found exception when running custom templatesPosted by woeliewoelie on Thursday, July 19, 2007
Yes I have, I will paste the output + stacktrace below:
Running Compiler...
ERROR: Trying to execute generate
Error Message: System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\Documents and Settings\{username}\Local Settings\Temp\cb9bre1x.dll' or one of its dependencies. The system cannot find the file specified. File name: 'file:///C:\Documents and Settings\{username}\Local Settings\Temp\cb9bre1x.dll' at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() at SubSonic.CodeGenerator.TurboCompiler.Run() in C:\SubSonic 2.0.3\src\SubSon
ic\CodeGeneration\CompileEngine.cs:line 97at SubCommander.Program.Main(String[] args) in C:\SubSonic 2.0.3\src\SubCommander\Program.cs:line 94If you look at the last part of the stacktrace it's pointing to C:\SubSonic 2.0.3\src. But I don't have SubSonic 2.0.3 in that location, is there a configsection I'm missing? I ran the subcommander from the program files location...
-
Re: Assembly not found exception when running custom templatesPosted by canofunk on Thursday, July 19, 2007
Ok, if the same stored procedures generate without the templateDirectory, but fails with it, there's gotta be an issue with the stored procedure template. Can you post or PM me the template file? (CS_SPTemplate.aspx or VB_SPTemplate.aspx)
-
Re: Assembly not found exception when running custom templatesPosted by subdigital on Friday, July 20, 2007
I updated to 2.0.3 and tried again with the default template and everything worked. I started to modify the template in a few places and I got the same error, but I realized that it was because I had invalid syntax in the template.
Fixing the template made it work again. Any thoughts on a template compiler?
Thanks!
-
Re: Assembly not found exception when running custom templatesPosted by spookytooth on Friday, July 20, 2007
Been finding out that the compiler crashes like this when there's an error in your templates. We used to have error traps in there but since we reshuffled in the name of speed I think we broke something ;).
When you see this error - it means your template isn't working ;)