N
news.microsoft.com
Hi!
My app consists of three parts:
1. Client app
2. A webservice with sourcecodefunctions
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 CompileAssemblyFromSourceBatch-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
csCompilerParameters.CompilerOptions = "/res:form.resource", 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
CompileAssemblyFromSourceBatch 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
CompilerParameters csCompilerParameters = new
CompilerParameters(strLibraries, "ClientDownload.dll", true);
// Generate a dll
csCompilerParameters.GenerateExecutable = false;
// Set tempfilescollection
csCompilerParameters.TempFiles = csTempFiles;
// Compile library
csCompilerResults =
csCodeCompiler.CompileAssemblyFromSourceBatch(csCompilerParameters,
strCode );
return csCompilerResults;
My app consists of three parts:
1. Client app
2. A webservice with sourcecodefunctions
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 CompileAssemblyFromSourceBatch-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
csCompilerParameters.CompilerOptions = "/res:form.resource", 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
CompileAssemblyFromSourceBatch 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
CompilerParameters csCompilerParameters = new
CompilerParameters(strLibraries, "ClientDownload.dll", true);
// Generate a dll
csCompilerParameters.GenerateExecutable = false;
// Set tempfilescollection
csCompilerParameters.TempFiles = csTempFiles;
// Compile library
csCompilerResults =
csCodeCompiler.CompileAssemblyFromSourceBatch(csCompilerParameters,
strCode );
return csCompilerResults;