Results 1 to 6 of 6

Thread: How to use CodeDom to dynamically create a Windows Form Application£¿

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9

    How to use CodeDom to dynamically create a Windows Form Application£¿

    Hi, everybody. I can use CodeDom to dynamically create a Windows Console Application(a exe file), like this:

    http://support.microsoft.com/default...NoWebContent=1

    But I don't know how to dynamically create a Windows Form Application(a exe file) use CodeDom£¿Who can help me? If you can write a very simple example(just need display a windows form) to guide me?I will thank you much!

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    The link you gave shows everything you need. Whats the problem?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9
    This Link can only dynamically create a Windows Console application. But I wanna dynamically create a Windows Form application use CodeDom.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Add the following

    Code:
    parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
    parameters.ReferencedAssemblies.Add("System.dll")
    parameters.MainClass = "Form1"

    test code to compile

    Code:
    Class Form1
       Inherits System.Windows.forms.Form
    
    End Class
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9
    To Cander, Thank you very much! I praise your technic!
    Now I can get a windows form appliction. And now, I wanna embed a resource file (a .rtf file) to the dynamically create windows form application. So I add this following code:

    parameters.Win32Resource = "my.rtf"

    But above code line result to compile error. The Error Number is BC31019, Error Text is "specified mapping file not include resource file". I don't know what the Error Text meaning.

    Can you give me a guide?

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    It has to be an actual Resource file (.rc?)

    Im not sure how to create those in .NET as I have the first version of Visual Studio and it doesnt have a Resource Editor. Maybe they added it to 2003. There are some ways to make them in code you can look up some info on.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width