NUnit - System.IO.FileNotFoundException - unit-testing

Im trying to load a .dll into Nunit which I have never used before(NUnit), when I try open the .dll in Nunit I get the following error. I have no idea whats going wrong , Google doesn't turn up much on this. Any suggestions?
System.IO.FileNotFoundException...
Server stack trace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Util.TestDomain.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.RemoteTestAgent.AgentRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Util.ProcessRunner.Load(TestPackage package)
at NUnit.Util.TestLoader.LoadTest(String testName)

Make sure that there is no development stage assembly in the GloballyAssemblyCache.
In my case, NUnit failed to load Npgsql.Tests.dll.
Npgsql.Tests.dll links to Npgsql.dll. However GAC has another variant of Npgsql.dll with same version.
If assembly has fully qualified reference name like Npgsql, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, .NET runtime tries to search assembly from GAC at first, and then search your local folder (Probes for the assembly). We can it check at msdn How the Runtime Locates Assemblies

Related

Sitecore Error: Could not create instance of type: Sitecore.Form.Core.WffmActionHandler. No matching constructor was found

Has anyone ran into the issue below? Basically, I am trying to upgrade the Web forms for Marketers from 8.0-U3 to 8.0-U4(successful) to 8.1-Initial release (not successful).
The error was during the update installation process:
http://upgrade/sitecore/admin/UpdateInstallationWizard.aspx
It says:
The installation has encountered a critical error.
This Sitecore installation cannot be used for either testing or
production purposes until Sitecore support is contacted. Make sure to
download and include the file containing diagnostic information about
your Sitecore installation.
Server Error in '/' Application.
Could not create instance of type: Sitecore.Form.Core.WffmActionHandler. No matching constructor was found.
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: Sitecore.Exceptions.ConfigurationException: Could not create instance of type: Sitecore.Form.Core.WffmActionHandler. No matching constructor was found.
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:
[ConfigurationException: Could not create instance of type: Sitecore.Form.Core.WffmActionHandler. No matching constructor was found.]
Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +272
Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +131
Sitecore.Events.EventSubscribers.Add(String eventName, XmlNode configNode) +545
Sitecore.Events.Event.GetConfigSubscribers() +564
Sitecore.Events.Event.RaiseEvent(String eventName, Object[] parameters) +338
Sitecore.Data.DataProviders.Sql.SqlDataProvider.SetProperty(String parameterName, String value, CallContext context) +259
Sitecore.Data.DataProviders.DataProvider.SetProperty(String name, String value, CallContext context, DataProviderCollection providers) +124
Sitecore.Data.DataManager.SetProperty(String name, String value) +103
Sitecore.Web.Authentication.TicketManager.IsTicketExpired(Ticket ticket, Boolean useProlongation) +330
Sitecore.Web.Authentication.TicketManager.GetTicket(String ticketId, Boolean returnExpired) +93
Sitecore.Web.Authentication.TicketManager.IsTicketValid(String ticketId) +37
Sitecore.Shell.Web.ShellPage.IsLoggedIn(Boolean returnAfterLogin) +409
Sitecore.Shell.Web.UI.SecurePage.OnLoad(EventArgs e) +22
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4498
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1073.0
I was able to fixed the issue. I reinstalled the update package of WFFM 8.1. But prior to that, I copy and pasted the DLLs and configuration files of WFFM 8.1-Initial release to my instance before undergoing under run of update.
Edited: Root cause, forgot to update the Sitecore.Forms.config with the patch below:
<handler type="Sitecore.Form.Core.WffmActionHandler, Sitecore.Forms.Core" method="OnWffmActionEventFired" >
<param name="actionManager" ref="/sitecore/wffm/wffmActionExecutor" /> </handler>
In my case i had fixed by copying entire DLL from clean-sitecore installation folder, When more dig on it who is black sheep is below they are
Sitecore.Forms.Core.dll
Sitecore.Forms.Custom.dll
Sitecore.Forms.Mvc.dll
Above dll's version differed.

Client Certificate Web Service Call

I have a requirement to call server web service with client certificate. They have provided me one .crt file. I am hosting my project in WindowsServer2008 IIS7.
I install .crt from right click properties, as i can't add certificate to Server Certificates by Complete Certificate Request. I got the error:
CertEnroll::CX509Enrollment::p_InstallResponse: ANSI bad tag value met.
I googled and found nothing on how to install .crt client certificate. Also tried installing as explaining here on step4.
And when i called like this
string certPath = Server.MapPath("../certificate/iot01.servername.crt");
X509Certificate2 cert = new X509Certificate2(certPath);
ws.ClientCertificates.Add(cert);
res = ws.methodName(params);
I got the error:
System.IO.IOException: The handshake failed due to an unexpected packet format. at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.TlsStream.CallProcessAuthentication(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.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async)
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at .....
Is this is related to my certificate installing and calling. Can someone point me where am i gone wrong.
The error clearly mentions "handshake failed". I suspect it is an SSL auth error because of a WSDL format mismatch.
You should check whether the format of your request, and that of the response are the same. They need to match to be able to communicate.
Microsoft Network Monitor can help you figure out the format.

Sitecore Edit User exception in User Manager

I am trying to figure out what might be wrong. Basically, I am not able to edit any user accounts. Once I click Edit in User Manager I get the attached exception.
Any advise would be much appreciated.
Sitecore version is 6.6.0 (rev 130214)
here is the exception from the log file:
**6136 11:49:33 FATAL An uncaught exception occurred
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Sitecore.Client
at Sitecore.Shell.Applications.Security.EditUser.EditUserPage.PlaceInFrame(String urlString)
at Sitecore.Shell.Applications.Security.EditUser.EditUserPage.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)**
I replaced the whole of the shell folder as suggested and the issue disappeared. I assume it was either missing or corrupt file.
Please try to replace your bin folder with fresh Sitecore dll's.

FirstData WebService giving error

My First data web service code is working fine on local machine. Followed Patricker answer here at stackoverflow Link To Code for WebService .Problem is when I deploy it on server I get error.
Am I missing any WebService DLL or dependency because I don't see anything in my deployable file created with VS2010 using Build Deployment Package for upload.
I have noticed onething in the error. Path is C:\Users\Chris\Documents\Visual Studio 2010... which is my local machine and the server is generated on the host server. Whats wrong?
ERROR
An internal error occurred.
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.Security.Cryptography.CryptographicException: An internal error occurred.
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:
[CryptographicException: An internal error occurred.
]
System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +33
System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0
System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +237
System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password) +80
DataFirstWebWebService.CLinkTransaction.BuildOrderService() in C:\Users\Chris\Documents\Visual Studio 2010\Projects\DataFirstWebWebService\DataFirstWebWebService\CLinkTransaction.cs:120
DataFirstWebWebService.CLinkTransaction.ChargeCreditCard(String cardNumber, String expMonth, String expYear, String ccv, Decimal chargeTotal, Billing billingInfo, CLinkTransResponse transResponse) in C:\Users\Chris\Documents\Visual Studio 2010\Projects\DataFirstWebWebService\DataFirstWebWebService\CLinkTransaction.cs:29
DataFirstWebWebService._default.Button1_Click(Object sender, EventArgs e) in C:\Users\Chris\Documents\Visual Studio 2010\Projects\DataFirstWebWebService\DataFirstWebWebService\default.aspx.cs:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

log4Net issues with NUnit (Tried v2.5.7, 2.5.2, 2.4.8, 2.4.7)

I'm getting an error (see bottom of post) when running NUnit against a production code assembly. The production code assembly has a reference to a third party framework that uses log4net internally (Specifically, this is SimplyAccounting's SDK). The version of log4net that it uses is 1.2.9.0. Outside of this third party framework which we use via the public api from the dll files, log4net is not part of our production code.
While troubleshooting, I eliminated the reference to the production code assembly from the unit test project and added a reference to the SimplyAccounting SDK. When I do this NUnit pukes out the following error. If the third party reference (or the production code reference) is not in the test project then Nunit runs fine. Any workarounds with a potential log4net conflict would be helpful. I'm using NUnit 2.5.2.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at log4net.Layout.LayoutSkeleton.get_Header()
at log4net.Appender.TextWriterAppender.WriteHeader()
at log4net.Appender.TextWriterAppender.set_Writer(TextWriter value)
--- End of inner exception stack trace ---
Server stack trace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at NUnit.Core.Log4NetCapture.SetAppenderTextWriter(TextWriter writer)
at NUnit.Core.Log4NetCapture.StartCapture()
at NUnit.Core.TextCapture.set_Enabled(Boolean value)
at NUnit.Core.RemoteTestRunner.StartTextCapture(EventListener queue)
at NUnit.Core.RemoteTestRunner.BeginRun(EventListener listener, ITestFilter filter)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.BeginRun(EventListener listener, ITestFilter filter)
at NUnit.Core.ProxyTestRunner.BeginRun(EventListener listener, ITestFilter filter)
at NUnit.Util.TestDomain.BeginRun(EventListener listener, ITestFilter filter)
at NUnit.Util.TestLoader.RunTests(ITestFilter filter)
at NUnit.UiKit.TestSuiteTreeView.RunTests(ITest[] tests, Boolean ignoreCategories)
at NUnit.UiKit.TestSuiteTreeView.RunSelectedTests()
at NUnit.UiKit.TestTree.RunSelectedTests()
at NUnit.Gui.NUnitForm.runButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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)
One solution (although pretty disruptive and not solving the root issue) would be to have your production assembly talk to an interface that wraps the SimplyAccount SDK instead of talking directly to it. Then your production code doesn't need to reference the SDK dll and you could test it freely by passing in a fake imlementation of the interface you created.
This has the design benefit of being decoupled from that SDK, but like I said, it could be quite disruptive to your codebase.