Compiling resources into assembly

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
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;
 
I can't answer your question but I have an alternative for you. Put your
images behind a web server and load them as you require them. For example,
to download and use an image list

Dim mwcWeb As System.Net.WebClient = New System.Net.WebClient

Private mstreamTreeViewImages As System.IO.Stream = =
mwcWeb.OpenRead("http://server/Images/imagelist.bmp")



imglstTreeView.Images.AddStrip(New
System.Drawing.Bitmap(mstreamTreeViewImages)) ' Add the image as a group of
images to an image list

One thing to remember, the stream must remain open while you are using the
image.

I hope this is useful

Mark
 
Back
Top