Compiling resources into assembly

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news.microsoft.com

    #1

    Compiling resources into assembly

    Hi!

    My app consists of three parts:
    1. Client app
    2. A webservice with sourcecodefunct ions
    3. Local "end-user-compiled library"

    The user does like this:
    1. Download small app from Internet
    2. Start application and login to my service
    3. Small app downloads source code and compiles an assembly for it to use

    So far so good. Everything works fine as long as I don't need any extra
    resources.

    For example: A Form with any Windows Forms control on it works fine. A form
    containg icons or an ImageList with icons doesn't work since I have to
    compile the resource into the assembly.

    I use the CompileAssembly FromSourceBatch-function to create my assembly. I
    read somewhere that .resx-files could be entered in the string [] as a part
    of the code to compile but it doesn't work.

    My problem is that I don't have physical resx-files. Only as string from my
    service and I really dont want to create any files locally on the client
    computer. I know that I can use resgen to make .resource-files and then add
    csCompilerParam eters.CompilerO ptions = "/res:form.resour ce", but since I
    don't want to create files it's not an option either.

    In other words... how do I create my assembly using
    CompileAssembly FromSourceBatch including my resx-files!!!

    Regards Kristian

    Here's how I do it. Pretty straight forward isn't it?
    // Create compiler
    csCodeCompiler = csCodeProvider. CreateCompiler( );

    // Add references

    CompilerParamet ers csCompilerParam eters = new
    CompilerParamet ers(strLibrarie s, "ClientDownload .dll", true);

    // Generate a dll

    csCompilerParam eters.GenerateE xecutable = false;

    // Set tempfilescollec tion

    csCompilerParam eters.TempFiles = csTempFiles;

    // Compile library

    csCompilerResul ts =
    csCodeCompiler. CompileAssembly FromSourceBatch (csCompilerPara meters,
    strCode );

    return csCompilerResul ts;



  • Tom

    #2
    Re: Compiling resources into assembly

    Just make them embedded Resources

    "news.microsoft .com" <netpet99@hotma il.com> wrote in message news:<#Qh4zIdhE HA.2544@TK2MSFT NGP10.phx.gbl>. ..[color=blue]
    > Hi!
    >
    > My app consists of three parts:
    > 1. Client app
    > 2. A webservice with sourcecodefunct ions
    > 3. Local "end-user-compiled library"
    >
    > The user does like this:
    > 1. Download small app from Internet
    > 2. Start application and login to my service
    > 3. Small app downloads source code and compiles an assembly for it to use
    >
    > So far so good. Everything works fine as long as I don't need any extra
    > resources.
    >
    > For example: A Form with any Windows Forms control on it works fine. A form
    > containg icons or an ImageList with icons doesn't work since I have to
    > compile the resource into the assembly.
    >
    > I use the CompileAssembly FromSourceBatch-function to create my assembly. I
    > read somewhere that .resx-files could be entered in the string [] as a part
    > of the code to compile but it doesn't work.
    >
    > My problem is that I don't have physical resx-files. Only as string from my
    > service and I really dont want to create any files locally on the client
    > computer. I know that I can use resgen to make .resource-files and then add
    > csCompilerParam eters.CompilerO ptions = "/res:form.resour ce", but since I
    > don't want to create files it's not an option either.
    >
    > In other words... how do I create my assembly using
    > CompileAssembly FromSourceBatch including my resx-files!!!
    >
    > Regards Kristian
    >
    > Here's how I do it. Pretty straight forward isn't it?
    > // Create compiler
    > csCodeCompiler = csCodeProvider. CreateCompiler( );
    >
    > // Add references
    >
    > CompilerParamet ers csCompilerParam eters = new
    > CompilerParamet ers(strLibrarie s, "ClientDownload .dll", true);
    >
    > // Generate a dll
    >
    > csCompilerParam eters.GenerateE xecutable = false;
    >
    > // Set tempfilescollec tion
    >
    > csCompilerParam eters.TempFiles = csTempFiles;
    >
    > // Compile library
    >
    > csCompilerResul ts =
    > csCodeCompiler. CompileAssembly FromSourceBatch (csCompilerPara meters,
    > strCode );
    >
    > return csCompilerResul ts;[/color]

    Comment

    • news.microsoft.com

      #3
      Re: Compiling resources into assembly

      Hi!

      Ok... I had that figured out, but I don't know how to do it.

      Do I have to make resource-files instead of resx-files? Tried that but I got
      compilation error.

      Kristian

      "Tom" <junkmale48@hot mail.com> wrote in message
      news:63d1c9f0.0 408200841.10bc7 aab@posting.goo gle.com...[color=blue]
      > Just make them embedded Resources
      >
      > "news.microsoft .com" <netpet99@hotma il.com> wrote in message[/color]
      news:<#Qh4zIdhE HA.2544@TK2MSFT NGP10.phx.gbl>. ..[color=blue][color=green]
      > > Hi!
      > >
      > > My app consists of three parts:
      > > 1. Client app
      > > 2. A webservice with sourcecodefunct ions
      > > 3. Local "end-user-compiled library"
      > >
      > > The user does like this:
      > > 1. Download small app from Internet
      > > 2. Start application and login to my service
      > > 3. Small app downloads source code and compiles an assembly for it to[/color][/color]
      use[color=blue][color=green]
      > >
      > > So far so good. Everything works fine as long as I don't need any extra
      > > resources.
      > >
      > > For example: A Form with any Windows Forms control on it works fine. A[/color][/color]
      form[color=blue][color=green]
      > > containg icons or an ImageList with icons doesn't work since I have to
      > > compile the resource into the assembly.
      > >
      > > I use the CompileAssembly FromSourceBatch-function to create my assembly.[/color][/color]
      I[color=blue][color=green]
      > > read somewhere that .resx-files could be entered in the string [] as a[/color][/color]
      part[color=blue][color=green]
      > > of the code to compile but it doesn't work.
      > >
      > > My problem is that I don't have physical resx-files. Only as string from[/color][/color]
      my[color=blue][color=green]
      > > service and I really dont want to create any files locally on the client
      > > computer. I know that I can use resgen to make .resource-files and then[/color][/color]
      add[color=blue][color=green]
      > > csCompilerParam eters.CompilerO ptions = "/res:form.resour ce", but since I
      > > don't want to create files it's not an option either.
      > >
      > > In other words... how do I create my assembly using
      > > CompileAssembly FromSourceBatch including my resx-files!!!
      > >
      > > Regards Kristian
      > >
      > > Here's how I do it. Pretty straight forward isn't it?
      > > // Create compiler
      > > csCodeCompiler = csCodeProvider. CreateCompiler( );
      > >
      > > // Add references
      > >
      > > CompilerParamet ers csCompilerParam eters = new
      > > CompilerParamet ers(strLibrarie s, "ClientDownload .dll", true);
      > >
      > > // Generate a dll
      > >
      > > csCompilerParam eters.GenerateE xecutable = false;
      > >
      > > // Set tempfilescollec tion
      > >
      > > csCompilerParam eters.TempFiles = csTempFiles;
      > >
      > > // Compile library
      > >
      > > csCompilerResul ts =
      > > csCodeCompiler. CompileAssembly FromSourceBatch (csCompilerPara meters,
      > > strCode );
      > >
      > > return csCompilerResul ts;[/color][/color]


      Comment

      Working...