2015-06-09 22 views
0

我已經安裝了nuget包log4net.Ext.Jsonfirst steps instructions從維基。log4net.ext.json:錯誤無法找到類型[log4net.Layout.SerializedLayout,log4net.Ext.Json]

不過,我在運行時獲得以下錯誤:

log4net:ERROR Failed to find type [log4net.Layout.SerializedLayout, log4net.Ext.Json] 
System.IO.FileNotFoundException: Could not load file or assembly 'log4net.Ext.Json' or one of its dependencies. The system cannot find the file specified. 
File name: 'log4net.Ext.Json' 
    at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) 
    at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) 
    at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) 
    at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) 
    at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase) 
    at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase) 
    at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint) 

=== Pre-bind state information === 
LOG: DisplayName = log4net.Ext.Json 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: log4net.Ext.Json | Domain ID: 1 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///<MyProject>/bin/Debug/ 
LOG: Initial PrivatePath = NULL 
Calling assembly : log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: <MyProject>\bin\Debug\log4net-googlecloudlogging-console.vshost.exe.Config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json.DLL. 
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.DLL. 
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json.EXE. 
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.EXE. 

log4net:ERROR Failed to create object to set param: layout 

我該如何解決這個問題?

回答

0

您的輸出/運行目錄中缺少dll log4net.Ext.Json.dll,或者dll log4net.Ext.Json.dll不包含類log4net.Layout.SerializedLayout。首先檢查dll,如果沒有,則將其複製到目錄中。

+0

謝謝@peer,但這聽起來不像是一個非常穩定的解決方案。如果我清理我的解決方案會怎樣我將不得不手動複製dll。這是某種程序集綁定的問題 - 我希望能找到一個永久的解決方案。 – urig

+0

你需要添加複製後發佈或在你的項目中引用到dll – Peter

相關問題