473,805 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CodeDom - Namespace/Class interaction between Ns1 and CodeDom's Ns2

9 New Member
Hello,

I was wondering if anyone might know the easiest way to access static methods through a namespace(MyNam espace) from CodeDom generated code?



Basically I have this in my MyNamespace.For m:

//////// Most of this below is almost useless jargon just to give an idea of what values are set or not
public CodeDom.Compile r.CodeDomProvid er provider = new Microsoft.CShar p.CSharpCodePro vider();

public System.CodeDom. Compiler.Compil erParameters parms = new System.CodeDom. Compiler.Compil erParameters();
parms.GenerateE xecutable = false;
parms.GenerateI nMemory = true;
parms.Reference dAssemblies.Add ("System.dll ");

public CodeCompileUnit compileUnit = new CodeCompileUnit ();

public CodeNamespace namespacee = new CodeNamespace(" CodeDomNamespac e");


namespacee.Impo rts.Add(new CodeNamespaceIm port("System")) ;
namespacee.Impo rts.Add(new CodeNamespaceIm port("MyNamespa ce"));

///End jargon above, my question below:

Currently in code:

public string code = @"pubilc static string StringTest()
{
return ""the test""
}
";

but I'd like the code string to say this:

public string code = @"public static string StringTest()
{
return MyNamespace.MyC lass.MyRoutine( "test");
}


And in MyRoutine...

public static string MyRoutine(strin g s)
{
s = s + "1";
return s;
}


However when I try this, I keep getting an error in my reflection setup:

Could not load file or assembly 'file:///C:\Users\rolo\A ppdata\Local\Te mp\przvq1_b.dll ' or one of its dependencies. The system cannot find the file specified.


I'm pretty new at this, it works fine as long as I don't try modify the string code to use "return MyNamespace.MyC lass.MyRoutine( "test"); " .

Any ideas on how to do this?
Oct 22 '08 #1
0 1191

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1925
by: Ron Bullman | last post by:
Hi, I havent been able to find any documentation about @ in the CodeDom context. The problem is when generating C# code from CodeDom it will associate a @-tag with all C# specific types. Why? And how to configure the CodeDom to generate code without @-tags? Ron A short example follows whic produces following kind of output:
0
1071
by: Shawn A. Hall | last post by:
First, I apologize if this isn't the right group to post this question, but I didn't see a newsgroup specific to CodeDom so here I am. On to my question: I am trying to use CodeDom to generate Method, Property, and Member code, but ONLY that code. It appears as though the only way to generate code is through the CodeGenerator/CodeProvider, which you have to attach a namespace then a class to the namespace then your members to that...
5
2500
by: Mark | last post by:
I'm using the CodeDom namespace to generate code. How do you specify that the method of a class should be static? I'm assuming I use the CodeMemberMethod class to define the method, but I'm not seeing the property of the class that would allow me to specify that the method should be static. Thanks in advance. Mark
3
3143
by: Mark | last post by:
I'm looking at the CodeDom namespace in .NET 2.0 class library online (http://msdn2.microsoft.com/library/za6cc751.aspx). I'm not seeing any class that would allow me to create Generics. Any suggestions? Thanks in advance. Mark
4
10185
by: Raja | last post by:
Have both .Net framework 1.1 and Framework 2.0 installed in my machine But, am unable to find out system.codedom.dll in my machine, one which, my application needs. Am not finding this dll in entire machine. Can anybody help me in getting this dll? Advance Thanks, Raja
2
2288
by: CodeMonkey775 | last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am trying to pass this list to an executable section of code which is compiled during run-time. The formulas are calculated in CodeDom and the result is returned on the same List<CellData> object I passed. The user-defined class which holds the cell data...
1
2971
by: Niels Ull | last post by:
Hi! I'm using .Net 2.0 and C#, and I'm trying to generate code for build time AOP. But I cannot find out how to generate an anonymous delegate. E.g. generating code like this: class MyClassWrapper {
1
4898
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I may have painted myself into a corner with GenerateInMemory=true. My app need a custom user step. Users want to code (sort of - they are not programmers) some refinements to a search procedure. They can concoct a moderately complex boolean expression, and that suffices. I will take their statements, add top and bottom text, and now I can do a CodeDom compile. I generate an assembly via CodeDom with GenerateInMemory. I make a...
0
1437
balabaster
by: balabaster | last post by:
I don't know if anyone's got any clue about this, but I have the following expression evaluator which makes use of the CodeDom to evaluate a VB.NET expression at runtime. This gives the system administrator the ability to add ad-hoc expressions onto the system, and when users execute these expressions, they are prompted for data for the arguments. Function Evaluate(ByVal Expression As String, ByVal Args() As Object) As Double If...
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.