Tech Off Thread

7 posts

Single .Net EXE problem (I'm THIS close to an e-mail deployment)

Back to Forum: Tech Off
  • User profile image
    Minh

    I recently discover ILMERGE, which lets you combine multiple .NET assemblies into 1 (I'm aiming for no-install apps -- just the 1 EXE). And it seems to be doing the job.

    I'm stuck at one part though, that stops my app from working. My .exe.config doesn't like being part of this merged assembly for some reason. Can someone tell me how to express this .config in code so that I can avoid the .config problem all together?

    <?xml version="1.0"?>
    <configuration>

        <configSections>
            <section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </configSections>

        <microsoft.web.services2>
            <diagnostics>
                <detailedErrors enabled="true" />
                <trace enabled="false" />
            </diagnostics>

            <filters>
                <input>
                    <add type="CompanyNamespace.DecompressionFilter, CompanyNamespace"/>
                </input>
                <output>
                    <add type="CompanyNamespace.CompressionFilter, CompanyNamespace"/>
                </output>
            </filters>
        </microsoft.web.services2>
    </configuration>

  • User profile image
    JohnAskew

    ILMerge, nice find. Thanks.

    I just found this utility that may be able to generate a config file...
    http://msdn2.microsoft.com/en-us/library/aa347733.aspx

    I'm not sure if it would help.

    ConfigurationManager seems to be file-based only...

    I wonder if the Enterprise Library's Configuration block has something?
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/config.asp

    Maybe there is (can be) a storage provider that pulls from memory instead of a file?


    EDIT: Of course, the EntLib dlls would need to be ILMerged in your case... I like the idea of ILMerge such that development could stay modular and deployment could meet with some client's 1-file desire.

  • User profile image
    JPeless

    Possible answer:

    Put the config file in the assembly as a resource, then, when launching the app, since it doesn't look like it needs anything in that config for first launching, save the resource to an actual file...

    Then you will have to only send out the EXE but in the end the file will be written for you.

    Of course, that doesn't allow you to keep it fully self-contained.

    As another point, unless you need to alter the config file after distribution, can't you just set the values programmatically for the code that uses it?

    I have done WCF code that creates config file sections and all that when setting up with a wizard and all, but doesn't require the config file and I set all the values programmatically...

    Jared

  • User profile image
    gdesroches

    The problem may be with the <add type=""> elements. When you merge multiple assebmlies into one, it probably only retains the main executable's assembly name. Try changing the assembly name in the "filters/input/add/@type" attributes to the executable's assembly name. The assembly name is the "CompanyNamespace" located after the comma.

  • User profile image
    Minh

    gdesroches wrote:
    The problem may be with the <add type=""> elements. When you merge multiple assebmlies into one, it probably only retains the main executable's assembly name. Try changing the assembly name in the "filters/input/add/@type" attributes to the executable's assembly name. The assembly name is the "CompanyNamespace" located after the comma.
    Aahh. You right. I will give this a try come Monday.

    Although, this will create different execution conditions depending on whether the assemblies are merged or not. Not a deal breaker because I like the single file better.

  • User profile image
    Minh

    Minh wrote:
    
    gdesroches wrote:The problem may be with the <add type=""> elements. When you merge multiple assebmlies into one, it probably only retains the main executable's assembly name. Try changing the assembly name in the "filters/input/add/@type" attributes to the executable's assembly name. The assembly name is the "CompanyNamespace" located after the comma.
    Aahh. You right. I will give this a try come Monday.

    Although, this will create different execution conditions depending on whether the assemblies are merged or not. Not a deal breaker because I like the single file better.
    Nope! this didn't work. when it was time for WSE to kick in, it complains of a configuration problem. Oh well, I'd like to See if I Could do this w/ code any way _ Since I'd like to avoid the config file & make it 1 exe

  • User profile image
    Minh

    Success!

    The code to implement the above .config file is

    DerivedWSE2Obj.Pipeline.InputFilters.Add(new DecompressionFilter());
    DerivedWSE2Obj.Pipeline.OutputFilters.Add(new CompressionFilter());

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.