Here is the code to test with. Create a new Form, add a button and put this code in the button.
Dim dbf As Data.Common.DbProviderFactory
'
' uncomment one of the below dbf =
'
'this fails
'dbf = Data.Common.DbProviderFactories.GetFactory("System.Data.SqlClient")
'these work
'dbf = Data.Common.DbProviderFactories.GetFactory("System.Data.Odbc")
'dbf = Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb")
Dim conn As Data.Common.DbConnection
conn = dbf.CreateConnection
The create connection only fails for SqlClient. The error is
System.TypeInitializationException was unhandled
HResult=-2146233036
Message=The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
Source=System.Data
TypeName=System.Data.SqlClient.SqlConnection
StackTrace:
at System.Data.SqlClient.SqlConnection..ctor()
at System.Data.SqlClient.SqlClientFactory.CreateConnection()
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\dewayne.basnett\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.InvalidOperationException
HResult=-2146233079
Message=Failed to read the configuration section for enclave providers. Make sure the section is correctly formatted in your application configuration file. Error Message: Configuration system failed to initialize
Source=System.Data
StackTrace:
at System.Data.SqlClient.SqlConnection..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
BareMessage=Configuration system failed to initialize
HResult=-2146232062
Line=0
Message=Configuration system failed to initialize
Source=System.Configuration
StackTrace:
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
at System.Configuration.Internal.InternalConfigRoot.OnConfigRemoved(InternalConfigEventArgs e)
at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String configPath, BaseConfigurationRecord configRecord)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Data.SqlClient.SqlConnection..cctor()
InnerException: System.Configuration.ConfigurationErrorsException
BareMessage=Unrecognized configuration section userSettings.
Filename=C:\Users\dewayne.basnett\AppData\Local\WindowsApplication1\WindowsApplication1.vshos_Url_odwpvb4iq0tpdwxwwhwkttkzifz10zja\1.0.0.0\user.config
HResult=-2146232062
Line=3
Message=Unrecognized configuration section userSettings. (C:\Users\dewayne.basnett\AppData\Local\WindowsApplication1\WindowsApplication1.vshos_Url_odwpvb4iq0tpdwxwwhwkttkzifz10zja\1.0.0.0\user.config line 3)
Source=System.Configuration
StackTrace:
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
InnerException:
EDIT: The config file is created by the IDE, but FWIW here it is
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<userSettings>
<WindowsApplication1.My.MySettings>
<setting name="AutoIncrement" serializeAs="String">
<value>False</value>
</setting>
</WindowsApplication1.My.MySettings>
</userSettings>
</configuration>
App.config contents
'FAILING
'<?xml version="1.0" encoding="utf-8"?>
'<configuration>
' <startup>
' <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
' </startup>
'</configuration>
'WORKING
'<?xml version="1.0" encoding="utf-8"?>
'<configuration>
' <configSections>
' <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
' <section name="WindowsApplication1.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
' </sectionGroup>
' </configSections>
' <startup>
' <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
' </startup>
' <userSettings>
' <WindowsApplication1.My.MySettings>
' <setting name="foo" serializeAs="String">
' <value/>
' </setting>
' </WindowsApplication1.My.MySettings>
' </userSettings>
'</configuration>
The answer, and I am not sure of the mechanics behind this, is...
Yesterday a user in another domain was trying to install one of my apps and setup was throwing an error. It looked like a permission problem but they insisted it was not. One of their programmers suggested that I change the properties of a code file from Do not copy to Copy always. I didn't think it would help, but they insisted. Eventually I figured out that it was how they were mapping to the install directory.
They had it as \fileserver.mo.gov\install. Changing it to \fileserver\install fixed the problem. I did not change the code file back.
As this problem became more bizarre I thought of what happened yesterday and remembered the change. I set it back to Do not copy, republished the app, and the above problem went away. As I said I don't understand the mechanics behind this, but my issue is resolved.
Related
I'm using nLog 4.0.1 in a Console Application in Visual Studio Express 2013.
Running the app in VS itself works; it works after compiling the .exe in a relative directory like bin\Debug or bin\Release, too.
However, it does not work if I compile it into another dir (\\192.168.3.55\vol3\programs\test).
This is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- ... -->
</assemblyBinding>
</runtime>
<connectionStrings>
<!-- ... -->
</connectionStrings>
<appSettings>
<!-- ... -->
</appSettings>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<variable name="startDatetime" value="${date:format=yyMMdd}" />
<targets>
<target name="logfile" xsi:type="File" fileName="\\192.168.3.71\log\test_${startDatetime}.dbg" layout="[${date:format=yyyyMMddHHmmssfff}][${level}] ${message}" />layout="${date:format=yyyyMMddHHmmss} ${message}" />-->
<target xsi:type="ColoredConsole" name="console" encoding="utf-8" layout="${message}">
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</nlog>
</configuration>
This is the part of my code where exception occurs:
Imports NLog
Module Test
Public logger As Logger = LogManager.GetCurrentClassLogger()
'...
End Module
This is the part of my .vbproj:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>\\192.168.3.55\vol3\programs\test\</OutputPath>
<DocumentationFile>test.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
This is the Stacktrace (sorry, it's in German):
Unbehandelte Ausnahme: System.TypeInitializationException: Der Typeninitialisierer für "test.Test" hat eine Ausnahme verursacht. ---> System.Configuration.ConfigurationErrorsException: Beim Erstellen des Konfigurationsabschnittshandlers für "nlog" ist ein Fehler aufgetreten.: Der Typeninitialisierer für "NLog.Config.Configuration
ItemFactory" hat eine Ausnahme verursacht. (\\192.168.3.55\vol3\programs\test\test.exe.Config line 36) ---> System.TypeInitializationException: Der Typeninitialisierer für "NLog.Config.ConfigurationItemFactory" hat eine Ausnahme verursacht. ---> System.IO.DirectoryNotFoundException: Ein Teil des Pfades "\\192.168.3.55\vol3\vol3\programs\test" konnte nicht gefunden werden.
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileSystemEnumerableIterator`1.CommonInit()
bei System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
bei System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption, Boolean checkHost)
bei System.IO.Directory.InternalGetFiles(String path, String searchPattern, SearchOption searchOption)
bei NLog.Config.ConfigurationItemFactory.BuildDefaultFactory()
bei NLog.Config.ConfigurationItemFactory..cctor()
--- Ende der internen Ausnahmestapelüberwachung ---
bei NLog.Config.ConfigurationItemFactory.get_Default()
bei NLog.Config.XmlLoggingConfiguration..ctor(XmlElement element, String fileName)
bei NLog.Config.ConfigSectionHandler.Create(XmlNode section, IAppDomain appDomain)
bei System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXml
Reader reader)
bei System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object pa
rentConfig, ConfigXmlReader reader)
bei System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
bei System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTruste
d, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
bei System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionReco
rd, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
bei System.Configuration.ConfigurationManager.GetSection(String sectionName)
bei NLog.LogFactory.get_Configuration()
bei NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
bei NLog.LogManager.GetCurrentClassLogger()
Means, part of the path \\192.168.3.55\vol3\vol3\programs\test could not be found, which really does not exist. But I don't know how it happened, that "vol3" is taken twice. I use \\192.168.3.55\vol3\programs\test\ in my settings, but, after releasing in exactly this directory, nLog turns the path into \\192.168.3.55\vol3\vol3\programs\test and fails.
How can I tell nLog to use the correct path?
This is a confirmed bug in 4.0.1 (not 4.0.0). This will be solved in 4.1.0.
We ran into the same problem. Downgrading NLog from 4.0.1 to 3.2.1 did the trick.
I'm testing Ninject, but following the how-to, i find it impossible to make it work. The information on the web is so messy even contradictory. I'm developping a website in MVC 4 on visual studio 2012 and i did install Ninject using Nuget.
So I get an error : "No parameterless constructor defined for this object.". As soon as I enter my controller.
I did the necessary steps :
Nuget installation
in NinjectWebCommon.cs, I did register my Interface in the RegisterServices method.
In my homecontroller I set my object like this :
public ISurvey _survey { get; set; }
[Inject]
public HomeController(ISurvey s)
{
_survey = s;
}
And I get the following error message :
Server Error in '/' Application.
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +6
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +110
[InvalidOperationException: An error occurred when trying to create a controller of type 'Surveys.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +438
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +226
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +326
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +177
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
So I wonder what did I do wrong ? 4 Hours on it, I found that there may be a problem with my web.config file or that It could be a reference missing, or it could be a factory missing. Right now I don't even know what to do. Thanks for your help.
You must also install Ninject.MVC3 (https://www.nuget.org/packages/Ninject.MVC3/) which includes the Ninject Controller Factory, that takes care of instantiating the controllers and injecting the right dependencies into the controller constructor. I am almost certain that if you install Ninject.MVC3 through Nuget, everything gets configured automaticaly.
Without this package, MVC uses its default controller factory, that knows nothing about injecting dependencies.
Check if in your Web.config you have two lines for MVC versioning, I had something like:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
If you do then replace them with one line like, to redirect to highest version that you are using in my case it's 4.0.0.1:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
This did it for me.
I'm trying to figure out how to use NServiceBus in combination withCommon.Logging. I just can not get it running. I try to develop a small demo application just for educational purpose.
What I did was:
1) Create a simple console application and imported Common.Logging and Common,Logging.NLog, added some Info messages and added an App.Config file:
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="DEBUG" />
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
</factoryAdapter>
</logging>
</common>
</configuration>
That worked just fine. But when I include NServiceBus:
var bus = Configure.With().DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional( true )
.UnicastBus()
.MsmqSubscriptionStorage()
.CreateBus()
.Start( () => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install() );
I get this exception:
System.TypeInitializationException was unhandled
Message=The type initializer for 'NServiceBus.Configure' threw an exception.
Source=NServiceBus.Core
TypeName=NServiceBus.Configure
StackTrace:
at NServiceBus.Configure.With()
at ConsoleApplication1.Program.Main(String[] args) in D:\Development\katas\ConsoleApplication1\ConsoleApplication1\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: Common.Logging.ConfigurationException
Message=ConfigurationReader Common.Logging.Configuration.DefaultConfigurationReader returned unknown settings instance of type Common.Logging.Configuration.LogSetting
Source=NServiceBus.Core
StackTrace:
at Common.Logging.Configuration.ArgUtils.Guard[T](Function`1 function, String messageFormat, Object[] args)
at Common.Logging.Configuration.ArgUtils.Guard(Action action, String messageFormat, Object[] args)
at Common.Logging.LogManager.BuildLoggerFactoryAdapter()
at Common.Logging.LogManager.get_Adapter()
at Common.Logging.LogManager.GetLogger(String name)
at NServiceBus.Configure..cctor()
InnerException: System.ArgumentOutOfRangeException
Message=Type 'Common.Logging.Configuration.LogSetting, Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' of parameter 'sectionResult' is not assignable to target type 'Common.Logging.Configuration.LogSetting, NServiceBus.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c'
Parameter name: sectionResult
Actual value was Common.Logging.Configuration.LogSetting.
Source=NServiceBus.Core
ParamName=sectionResult
StackTrace:
at Common.Logging.Configuration.ArgUtils.AssertIsAssignable[T](String paramName, Type valType, String messageFormat, Object[] args)
at Common.Logging.Configuration.ArgUtils.AssertIsAssignable[T](String paramName, Type valType)
at Common.Logging.LogManager.<>c__DisplayClass3.<BuildLoggerFactoryAdapter>b__1()
at Common.Logging.Configuration.ArgUtils.<>c__DisplayClass13.<Guard>b__12()
at Common.Logging.Configuration.ArgUtils.Guard[T](Function`1 function, String messageFormat, Object[] args)
InnerException:
I've already tried several things suggested in StackOverflow and other groups, but I just can't get it working. Can anyone offer some advice on how to approach this? Or provide a simple example?
This setup shouldn't be to fancy, right? I don't even need logging for the NServiceBus part for now.
Thanks!
NServiceBus has it's own version of Common.Logging that is ilmerged and internalized into the Core dll, that it uses to configure it's own logging (using log4net). When it starts up it discovers the configuration section in your app.config and tries to load it. However, your configuration section (called "logging") points to the external Common.Logging dll:
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
Where NSB wants it to look like:
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, NServiceBus.Core" />
Because of this, NSB throws an error. This is most certainly a bug in NSB. I suggest you create an issue on their github project.
While maybe not the most optimal solution in your case, the quickest way to work around it is to delete the logging section in app.config and configure Common.Logging in code. Or, skip using Common.Logging altogether and use NLog directly.
I might add that this problem will go away in NSB 4.0 where Common.Logging is not used anymore.
I have a simple WCF service hosted on IIS. Anytime I change the web.config file the service goes down and shows the following error:
Could not load file or assembly
'AutoMapper, Version=1.1.0.188,
Culture=neutral,
PublicKeyToken=be96cd2c38ef1005' or
one of its dependencies. Logon
failure: unknown user name or bad
password. (Exception from HRESULT:
0x8007052E)
To correct it, I need to delete all existing files and re-publish the WCF service. Re-publishing without deleting old files doesn't work, and neither does restarting the iis server.
Does anyone know why this happens? Or if there is an alternative to republishing the service to bring it back up? I am using IIS on Windows Server 2003, which I think is 6.0, and .Net framework 4.0
Further Error Info...
Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'AutoMapper, Version=1.1.0.188,
Culture=neutral,
PublicKeyToken=be96cd2c38ef1005' could
not be loaded.
WRN: Assembly binding logging is
turned OFF. To enable assembly bind
failure logging, set the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog]
(DWORD) to 1. Note: There is some
performance penalty associated with
assembly bind failure logging. To turn
this feature off, remove the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load
file or assembly 'AutoMapper,
Version=1.1.0.188, Culture=neutral,
PublicKeyToken=be96cd2c38ef1005' or
one of its dependencies. Logon
failure: unknown user name or bad
password. (Exception from HRESULT:
0x8007052E)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName
fileName, String codeBase, Evidence
assemblySecurity, RuntimeAssembly
locationHint, StackCrawlMark&
stackMark, Boolean
throwOnFileNotFound, Boolean
forIntrospection, Boolean
suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName
fileName, String codeBase, Evidence
assemblySecurity, RuntimeAssembly
locationHint, StackCrawlMark&
stackMark, Boolean
throwOnFileNotFound, Boolean
forIntrospection, Boolean
suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence
assemblySecurity, StackCrawlMark&
stackMark, Boolean forIntrospection,
Boolean suppressSecurityChecks) +132
System.Reflection.RuntimeAssembly.InternalLoad(String
assemblyString, Evidence
assemblySecurity, StackCrawlMark&
stackMark, Boolean forIntrospection)
+144 System.Reflection.Assembly.Load(String
assemblyString) +28
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[]
baseAddresses) +208
System.ServiceModel.HostingManager.CreateService(String
normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +615
[ServiceActivationException: The
service
'/Services/ClientLoginService.svc'
cannot be activated due to an
exception during compilation. The
exception message is: Could not load
file or assembly 'AutoMapper,
Version=1.1.0.188, Culture=neutral,
PublicKeyToken=be96cd2c38ef1005' or
one of its dependencies. Logon
failure: unknown user name or bad
password. (Exception from HRESULT:
0x8007052E).]
System.Runtime.AsyncResult.End(IAsyncResult
result) +679246
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
context, String
routeServiceVirtualPath, Boolean
flowContext, Boolean ensureWFService)
+234 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object
sender, EventArgs e) +355
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+75
I am sorry I am posting this question again. I googled for it and found many posts and threads on stackoverflow and other ones, but none wokred for me.
I get this error message when I run my Windows Forms Application.
Here is my App.config file:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="NHibernate.Test">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
<property name="connection.connection_string">
Data Source=nhibernate.db;Version=3;New=True;
</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="query.substitutions">true=1;false=0</property>
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu
</property>
</session-factory>
</hibernate-configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I am using Visual Studio 2010, on Windows Server 2008 R2 64 Bit.
My project configuration is X86, and I tried the x86, x64 and ManagedOnly versions of the System.Data.SQLite.dll file, but none seemed to work.
Can anyone please help me with this?
P.S: I know there are similar threads to this one, but please don't close this thread because none of the solutions have worked for me.
Thanks.
Here is the error:
NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLiteDriver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly SQLite.NET could not be found. Ensure that the assembly SQLite.NET is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SQLiteDriver..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
--- End of inner exception stack trace ---
at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
at NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings)
at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings)
at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
at NHibernate.Cfg.Configuration.BuildSettings()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at Employee.App.SessionProvider.get_Session() in C:\Users\Ako\documents\visual studio 2010\Projects\Employee\Employee.App\SessionProvider.cs:line 28
at Employee.App.EmployeeManager.get_Session() in C:\Users\Ako\documents\visual studio 2010\Projects\Employee\Employee.App\EmployeeManager.cs:line 14
at Employee.App.EmployeeManager.Save(Employee employee) in C:\Users\Ako\documents\visual studio 2010\Projects\Employee\Employee.App\EmployeeManager.cs:line 56
at Employee.App.frmMain.frmMain_Load(Object sender, EventArgs e) in C:\Users\Ako\documents\visual studio 2010\Projects\Employee\Employee.App\frmMain.cs:line 23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The error appears to be with the driver creation, this suggests to me that the driver is not installed on your system correctly. I've just tested this and it works for me (ok I'm using monodevelop, not VS), I installed the Sqlite driver from here:
ADO.NET 2.0 Provider for SQLite
I then used this in my app.config file:
<session-factory>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
<property name="connection.connection_string">Data Source=SimpleExample.sqlite;Version=3</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<mapping assembly="SimpleExample" />
</session-factory>
it appears that the SQLite assembly is not loaded hence the error:
Could not create the driver from NHibernate.Driver.SQLiteDriver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly SQLite.NET could not be found. Ensure that the assembly SQLite.NET is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.
you could preload the assembly using:
PreLoadAssembliesFromPath(AppDomain.CurrentDomain.BaseDirectory);
private static void PreLoadAssembliesFromPath(string p)
{
//S.O. NOTE: ELIDED - ALL EXCEPTION HANDLING FOR BREVITY
//get all .dll files from the specified path and load the lot
FileInfo[] files = null;
//you might not want recursion - handy for localised assemblies
//though especially.
files = new DirectoryInfo(p).GetFiles("*.dll",SearchOption.AllDirectories);
AssemblyName a = null;
string s = null;
foreach (var fi in files)
{
s = fi.FullName;
//now get the name of the assembly you've found, without loading it
//though (assuming .Net 2+ of course).
a = AssemblyName.GetAssemblyName(s);
//sanity check - make sure we don't already have an assembly loaded
//that, if this assembly name was passed to the loaded, would actually
//be resolved as that assembly. Might be unnecessary - but makes me
//happy :)
if (!AppDomain.CurrentDomain.GetAssemblies().Any(assembly =>
AssemblyName.ReferenceMatchesDefinition(a, assembly.GetName())))
{
//crucial - USE THE ASSEMBLY NAME.
//in a web app, this assembly will automatically be bound from the
//Asp.Net Temporary folder from where the site actually runs.
Assembly.Load(a);
}
}
}