Ich schreibe eine Konsolenanwendung für die Arbeit mit Dynamics CRM. Ich habe die XML-Konfigurationsdatei für die Anwendung wie folgt angegeben:Beim Erstellen einer C# -Konsolenanwendung wird eine XML-Konfigurationsdatei bearbeitet und die Anwendung beim Start abgestürzt.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<configSections>
<section name="microsoft.xrm.client" type="Microsoft.Xrm.Client.Configuration.CrmSection, Microsoft.Xrm.Client" />
</configSections>
<connectionStrings>
<add name="Xrm" connectionString="Server=XXXX://XXXXXXX:XXXX/XXXX; Domain=XXXXXXX; Username=XXXXXX; Password=XXXXXX" />
</connectionStrings>
<microsoft.xrm.client>
<contexts>
<add name="Xrm" type="Xrm.XrmServiceContext, Xrm" />
</contexts>
</microsoft.xrm.client>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.ServiceBus" publicKeyToken="XXXXXXXX" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
jedoch auf Gebäude und die Konsolenanwendung ausgeführt wird, ist es nicht das <startup>
-Tag überhaupt nicht mochte und abgestürzt ist, wird folgende Fehler erhöhen:
Unhandled Exception: System.Configuration.ConfigurationErrorsException: Configur
ation system failed to initialize ---> System.Configuration.ConfigurationErrorsE
xception: Only one <configSections> element allowed per config file and if prese
nt must be the first child of the root <configuration> element. (C:\Users\admini
strator.XXXX\Desktop\XXXXX\XXXX\XXXXX\XXXXX\XXXXX
XXXXXX.exe.Config line 6)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignor
eLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(Configurat
ionSchemaErrors schemaErrors)
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Intern
al.IInternalConfigSystem.GetSection(String sectionName)
at Microsoft.Xrm.Client.Configuration.CrmConfigurationManager.CreateProvider(
)
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Microsoft.Xrm.Client.CrmOrganizationServiceContext..ctor(String contextNam
e)
at Xrm.XrmServiceContext..ctor(String contextName) in C:\Users\XXXXXX\
Desktop\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX\XXXXX\XXX
XXXXXX\Xrm.cs:line 245616
at XXXXXXXX.consoleApp.Main(String[] args) in C:\Users\XXXXX
\XXXX\XXXXX\XXXXX\XXXXXX\XXXXX\XXXXXXX\XXXXX\XXXXX\XXXX
XXXXX\XXXXX.cs:line 22
So von der Fehlerdefinition, ich dachte, ich würde das Startup-Tag manuell entfernen, so dass die <configSections>
wäre oben. Das Ausführen hat wieder geklappt (es hat die Daten erfasst, die ich von CRM wollte). Nach einigen weiteren Arbeiten und dem erneuten Erstellen der Anwendung wurde das Tag <startup>
automatisch injiziert und daher stürzte die App erneut ab. Gibt es eine saubere Möglichkeit, das Hinzufügen des Tags <startup>
zu verhindern?
Start-Tag nicht entfernen. Verschieben Sie es bis zum Ende und versuchen Sie es? –
Welche Version von Visual Studio? –
Setzen Sie das '' Tag in einem anderen Abschnitt wird immer noch entfernt werden und oben wieder beim Erstellen der App hinzugefügt werden –
jablesauce