HighTechTalks DotNet Forums  

Dynamic Code Referenced Assemblies from ASP.NET

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss Dynamic Code Referenced Assemblies from ASP.NET in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jeronimo Bertran
 
Posts: n/a

Default Dynamic Code Referenced Assemblies from ASP.NET - 09-28-2006 , 09:52 PM






Hello,

I have creatred a dll that uses CodeDom to generate and exectue dynamic
code.

Basically the dll creates a new assembly by loading some user defined
code from a database, compiles it and runs it a certain number of times.

The process works very well when I use it from a Windows Forms
application. I am now trying to use the same dll to invoke dynamic
execution from an ASP.NET page. I am sure I will run into different
problems, but my first problem is that the compiler is not able to
locate the referenced assemby dll files. Here is some detail:

CodeDom.Compiler.CompilerParameters compilerParameters;

......

compilerParameters.ReferencedAssemblies.Add("MyAss embly.dll");

when I try to compile the code using:

compilerResults = provider.CompileAssemblyFromDom(compilerParameters ,
codeCompileUnit);


I get an error "Metadata file 'MyAssembly.dll' could not be found.

The file MyAssemby.dll is in the bin directory of the WebSite directory.
I also tried adding the assembly as "bin/MyAssenby.dll" with the same
result.

Also, once I am able to compile the assembly, is there a specific
location I should use for it?

Thanks,

Jeronimo Bertran

Reply With Quote
  #2  
Old   
Luke Zhang [MSFT]
 
Posts: n/a

Default RE: Dynamic Code Referenced Assemblies from ASP.NET - 09-29-2006 , 01:36 AM






Hello,

You may make that the account used by your ASP.NET application has enough
permission to access the folder/files. When lack of permission, there will
be such a file not found error. For example, you may check what the
authentication your ASP.NET application used, and if anonymous and
impersoante is enabled.

Second, you may change the code as following:

compilerParameters.ReferencedAssemblies.Add(Server .MapPath(".")+"\\MyAssembl
y.dll");

Server.MapPath(".") will return the phiscal path of current ASP.NET
application, and this may guide it find the file.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.




Reply With Quote
  #3  
Old   
Jeronimo Bertran
 
Posts: n/a

Default RE: Dynamic Code Referenced Assemblies from ASP.NET - 09-29-2006 , 06:20 PM



Luke,

Thanks for your help. Path.Combine(Using Server.MapPath("."), "bin")
solved the problem.

I am still having some problems invoking the scripts but will look into it
before asking.

Jeronimo Bertran

Reply With Quote
  #4  
Old   
Luke Zhang [MSFT]
 
Posts: n/a

Default RE: Dynamic Code Referenced Assemblies from ASP.NET - 10-01-2006 , 10:22 PM



Hello Jeronimo,

Thank you for the information. For any further questions, please feel free
to post in our community.

Sincerely,

Luke Zhang

Microsoft Online Community Support
This posting is provided "AS IS" with no warranties, and confers no rights.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.