.net - FileNotFoundException in Visual Studio Setup and Deployment Project when trying to load custom config -


I'm trying to call a custom action call within my setup; To update some items within app.config on my app, deployment project I've wrapped the custom configuration section in general, for example:

  [Configuration property ("Service Provider", ISRAEFire = true)] Public String Service Provider {Received {Return (String) Base {"Service Provider"]; } Set {base ["dataProviderFactory"] = value; }}  

I have called custom action after the base during the installation section of the installation. The installer code is:

  string exePath = string.format ("{0} MyApp.exe", reference parameter ["DP_TargetDir"]); SysConfig.Configuration config = ConfigManager.OpenExeConfiguration (exePath); Configuration. MyApp section = Configuration.MyApp) config.GetSection ("MyApp");  

When I run it, I get this error:

The system Configuration. Configuration eroser exception: There was an error in creating configuration section handles for my app: A file from the load file or assembly 'MyCompany MyApp.configuration' or its dependency failed to detect the specified file. (C: \ program files \ MyCompany \ MyApp \ MyApp.exe.config line 5) ---> System.IO.FileNotFoundException: Could not load one of the files or assemblies 'MyCompany.MyApp.configuration' or its dependencies . The system can not specify the file.

The query is in line 5:

  & lt; Section name = "mypad" type = "mycompany configuration.map app, microphone.maype.config configuration" requirePermission = "false" />  

The class library (as being the only class in that library) with the installer code is in the context of config assembly.

Is something really clear that 'I'm missing out here?'

Any help / suggestions will be highly appreciated. I have managed to find some code on MSDN (which hacked a thing to do so) I

Gaya) offers. Here's the link:.

Not to be able to debug with suggestions from suggestions, so thank you both for this.

For reference, my last installed code is:

  Install public override zero (IDictionary stateSaver) {base.Install (stateSaver); String target directory = reference Parameter ["DP_TargetDir"]; StateSaver.Add ("TargetDir", targetDirectory); String exePath = Path.Combine (target directory, "MyApp.exe"); System.Diagnostics.Debugger.Break (); ResolveEventHandler tempResolveEventHandler = (Sender, Args) = & gt; {String simpleName = new assembly name (args.Name) .name; String path = path. Cobain (target directory, simple name + ".dll"); Return file Example (path)? Assembly.LoadFrom (path): zero; }; Try {// Hook-Up ASM Handler AppDomain.CurrentDomain.AssemblyResolve + = tempResolveEventHandler; System.configuration.Configuration config = ConfigurationManager.OpenExeConfiguration (exePath); Configuration. Map section = (Configuration MyPass) Configuration. Section ["muep"]; If (section! = Zero) {// "ApplicationSettings.DefaultDatabasePath" is the custom config value that I am updating section. Application settings DefaultDatabasePath = Environmental Gatefolder Path (Environmental Specialfolder. General Announcement Data); Config.Save (); }} Finally remove {// ASM handler solution AppDomain.CurrentDomain.AssemblyResolve - = tempResolveEventHandler; }}  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -