473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Parameters for CodeDom compiled code can't convert

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 is defined here:

Expand|Select|Wrap|Line Numbers
  1. public class CellData
  2. {
  3. private int row;
  4. private int level;
  5. private int column;
  6. private string formula;
  7. private object result;
  8. private List<CellData> children;
  9.  
  10. public int Row { get { return row; } set { row = value; } }
  11. public int Column { get { return column; } set { column = value; } }
  12. public int Level { get { return level; } set { level = value; } }
  13. public string Formula { get { return formula; } set { formula = value; } }
  14. public object Result { get { return result; } set { result = value; } }
  15. public List<CellData> Children { get { return children; } set { children = value; } }
  16.  
  17. // Constructor
  18. public CellData(int CellRow, int CellColumn, int CellLevel, string CellFormula)
  19. {
  20. row = CellRow;
  21. column = CellColumn;
  22. formula = CellFormula;
  23. level = CellLevel;
  24.  
  25. children = new List<CellData>();
  26. }
  27. }

Since I needed the compiled CodeDom code to know what a CellData object was, I replicated that within the CodeDom code. The compiled code looks something like this:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. namespace C_Tech_Programmer
  6. {
  7. public class Code
  8. {
  9. // Calculate all of the formulas
  10. public List<CellData> Calculate(List<CellData> calcList)
  11. {
  12. calcList[0].Result = 7 * 7 * 9;
  13. return calcList;
  14. }
  15. }
  16.  
  17. public class CellData
  18. {
  19. private int row;
  20. private int level;
  21. private int column;
  22. private string formula;
  23. private object result;
  24. private List<CellData> children;
  25. public int Row { get { return row; } set { row = value; } }
  26. public int Column { get { return column; } set { column = value; } }
  27. public int Level { get { return level; } set { level = value; } }
  28. public string Formula { get { return formula; } set { formula = value; } }
  29. public object Result { get { return result; } set { result = value; } }
  30. public List<CellData> Children { get { return children; } set { children = value; } }
  31.  
  32. // Constructor
  33. public CellData(int CellRow, int CellColumn, int CellLevel, string CellFormula)
  34. {
  35. row = CellRow;
  36. column = CellColumn;
  37. formula = CellFormula;
  38. level = CellLevel;
  39.  
  40. children = new List<CellData>();
  41. }
  42. }
  43. }
To executed the compiled code, I pass my list of CellData objects to the Invoke method for the CodeDom code.

Expand|Select|Wrap|Line Numbers
  1. List<CellData> result = new List<CellData>();
  2.  
  3. result = (List<CellData>)mi.Invoke(assemblyInstance, new object[] { calcOrder });

The problem is that it won't make the conversion from the CellData class in my normal code to the CellData class in the CodeDom compiled code. This is the error that comes up:

{"Object of type 'System.Collections.Generic.List`1[C_Tech_Programmer.CellData]' cannot be converted to type 'System.Collections.Generic.List`1[C_Tech_Programmer.CellData]'."}

I have checked both classes over and they look exactly the same to me. If there is some sort of way to convert these, or even a better way to go about doing this, I would be much obliged to know how.

Thanks,
Dan
Aug 1 '07 #1
2 2243
Plater
7,872 Expert 4TB
Why use two different declarations of the class?
Define the class once and then allow it to be used by both sides?
Aug 1 '07 #2
Since I'm using CodeDom, it takes a source file as a string and compiles and executes that code within the application you are running. So it's pretty much in a complete different instance of what the application itself is. It can't reference the class if I put it in a design time.
Aug 1 '07 #3

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

Similar topics

2
by: Guillaume | last post by:
I don't think I'm the only one with this challenge so… I made code with the CodeDom classes and made code to create a new solution and a new project Now I want to get the codedom code in the new...
1
by: John Livermore | last post by:
Hello, We have an application that uses CodeDom for dynamic in-memory compilation of code. The same code (library) is used by both an ASP.net web site and a Windows Service. The code runs fine...
11
by: Leroy | last post by:
Hello, I have a question regarding the maximum number of parameters that can be passed to a procedure. In VB 6 the max was 60. What is the max for Dot Net? please and thanks.
3
by: Alexey Lavnikov | last post by:
I'm playing with CodeDOM and CSharpCodeProvider. I've found the following possibilities: CodeDOM -> Assembly C# Source code -> Assembly I miss the C# Source code -> CodeDOM only. Is it there?...
5
by: BuddyWork | last post by:
Hello, Can CodeDom be used to read an existing CS file.
0
by: Eric | last post by:
Does anyone know how to create a parameter on a method using CodeDOM that is optional or has a default value? I can get the parameters added to the method but I can't get the optional part...
6
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
0
by: =?ISO-8859-1?Q?Jan_Thom=E4?= | last post by:
Hi, I've been trying like a madman to make my WSDL work with .net, but it seems I am out of luck. Whenever I add a service reference to Visual C#, the code gets generated fine, however all...
0
by: thisismykindabyte | last post by:
Hello, I was wondering if anyone might know the easiest way to access static methods through a namespace(MyNamespace) from CodeDom generated code? Basically I have this in my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.