Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Configuration and il-repack #93

Open
chipitsine opened this issue May 20, 2015 · 1 comment
Open

System.Configuration and il-repack #93

chipitsine opened this issue May 20, 2015 · 1 comment

Comments

@chipitsine
Copy link

for example, I have the following App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="MyConfig" type="auth.Config,  auth" />
  </configSections>
  <MyConfig NAS_IDENTIFIER="OpenVpn">
    <servers>
      <server name="radius1.kontur" authport="1818" wait="77" sharedsecret="secret1" />
      <server name="radius2.kontur" retries="7" sharedsecret="secret2" />
    </servers>
  </MyConfig>
</configuration>

(main assembly is auth.exe),

after I merge some DLL into it like

<Target Name="AfterBuild">
  <ItemGroup>
    <MergeAssemblies Include="$(OutputPath)\$(AssemblyName).exe" />
    <MergeAssemblies Include="$(OutputPath)\Radius.dll" />
  </ItemGroup>
  <PropertyGroup>
    <OutputAssembly>$(OutputPath)\$(AssemblyName).standalone.exe</OutputAssembly>
    <Merger Condition="('$(OS)' == 'Windows_NT')">&quot;$(SolutionDir)\packages\ILRepack.1.26.0\tools\ILRepack.exe&quot;</Merger>
    <Merger Condition="('$(OS)' != 'Windows_NT')">mono --runtime=v4.0.30319 &quot;$(SolutionDir)\packages\ILRepack.1.26.0\tools\ILRepack.exe&quot;</Merger>
  </PropertyGroup>
  <Message Text="MERGING: @(MergeAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
  <Exec Command="$(Merger) /out:&quot;$(OutputAssembly)&quot; @(MergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
</Target>

I'm getting the following error when I start auth.standalone.exe:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for auth.Config ---> System.Configuration.ConfigurationErrorsException: Type 'auth.Config, auth' not found.
at System.Configuration.InternalConfigurationHost.GetConfigType (System.String typeName, Boolean throwOnError) [0x00000] in :0
at System.Configuration.ConfigInfo.CreateInstance () [0x00000] in :0
at System.Configuration.SectionInfo.CreateInstance () [0x00000] in :0
at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in :0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in :0
at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in :0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0
at auth.Config..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at auth.Program.Main (System.String[] args) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for auth.Config ---> System.Configuration.ConfigurationErrorsException: Type 'auth.Config, auth' not found.
at System.Configuration.InternalConfigurationHost.GetConfigType (System.String typeName, Boolean throwOnError) [0x00000] in :0
at System.Configuration.ConfigInfo.CreateInstance () [0x00000] in :0
at System.Configuration.SectionInfo.CreateInstance () [0x00000] in :0
at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in :0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in :0
at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in :0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0
at auth.Config..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at auth.Program.Main (System.String[] args) [0x00000] in :0

the fix is obvious, I have to rename

<section name="MyConfig" type="auth.Config,  auth" />

to

<section name="MyConfig" type="auth.Config,  auth.standalone" />

can il-repack do such magic ?

@gluck
Copy link
Owner

gluck commented May 20, 2015

ILRepack can do magic, definitely 🔮
ConfigMerger already takes care of those config files (simply concat'ing their content).

If serialized type names can be easily identified in those configs, it should remap them.

Open for a contribution there if you feel like doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants