AppDomainUnloadedException when TFS is cloning git repos for a build - c#

Suddenly, when queuing builds in TFS based on a git team project, I get the following stack trace.
Exception Message: Attempted to access an unloaded AppDomain. (type
AppDomainUnloadedException) Exception Stack Trace: Server stack
trace: at
LibGit2Sharp.Core.NativeMethods.git_clone(RepositorySafeHandle& repo,
String origin_url, FilePath workdir_path, GitCloneOptions& opts) at
LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir,
GitCloneOptions& opts) at LibGit2Sharp.Repository.Clone(String
sourceUrl, String workdirPath, CloneOptions options) at
Microsoft.TeamFoundation.Build.Activities.Git.GitPull.GitClone.GetRepository(String
repositoryUrl, String workingFolder, Boolean checkoutSubmodules) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message
reqMsg, Boolean bProxyCase) at System.Func4.EndInvoke(IAsyncResult
result) at
Microsoft.TeamFoundation.Build.Activities.Git.GitPull.GitRepositoryBase.EndExecute(AsyncCodeActivityContext
context, IAsyncResult result) at
System.Activities.AsyncCodeActivity1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext
context, IAsyncResult result) at
System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor
executor, BookmarkManager bookmarkManager)
I changed nothing for this to happend, googling so far I found info about it perhaps being macafee, but we dont use that on our build agent.
Using an on-premises build server
Normal TFS team projects build as expected

Resolved by restarting the server - not sure how I didn't think of that.

Related

VS 2013 could not resolve COM reference (STG_E_PATHNOTFOUND)

Good Day. I have a COM dll which registered using regsvr32 utility. When I tried to add reference to a project, the library is visible in reference list but when I press OK button the error occurs (STG_E_PATHNOTFOUND). Also popup hint on reference in browser shows correct path and dll not moved anywhere from it's registered location. Project and dll have same x64 bitness.
StackTrace
Error 1 The "ResolveComReference" task failed unexpectedly.
System.IO.DirectoryNotFoundException: The path could not be found. (Exception from HRESULT: 0x80030003 (STG_E_PATHNOTFOUND))
Server stack trace:
at System.Runtime.InteropServices.ComTypes.ITypeLib.GetDocumentation(Int32 index, String& strName, String& strDocString, Int32& dwHelpContext, String& strHelpFile)
at System.Runtime.InteropServices.Marshal.GetTypeLibName(ITypeLib typelib)
at Microsoft.Build.Tasks.ComReference.GetTypeLibNameForITypeLib(TaskLoggingHelper log, Boolean silent, ITypeLib typeLib, String typeLibId, String& typeLibName)
at Microsoft.Build.Tasks.ComReferenceInfo.InitializeWithPath(TaskLoggingHelper log, Boolean silent, String path, ITaskItem originalTaskItem, String targetProcessorArchitecture)
at Microsoft.Build.Tasks.ComReferenceInfo.InitializeWithTypeLibAttrs(TaskLoggingHelper log, Boolean silent, TYPELIBATTR tlbAttr, ITaskItem originalTaskItem, String targetProcessorArchitecture)
at Microsoft.Build.Tasks.ResolveComReference.ConvertAttrReferencesToComReferenceInfo(List`1 projectRefs, ITaskItem[] typeLibAttrs)
at Microsoft.Build.Tasks.ResolveComReference.Execute()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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 Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.CommandLine.OutOfProcTaskAppDomainWrapperBase.InstantiateAndExecuteTask(IBuildEngine oopTaskHostNode, LoadedType taskType, String taskName, String taskLocation, String taskFile, Int32 taskLine, Int32 taskColumn, AppDomainSetup appDomainSetup, IDictionary`2 taskParams)

How to fix TFS build issue "ResolveComReference" task failed unexpectedly process can't access file System.Windows.Interactivity.resources.dll'

I have a WPF solution and I'm using Visual Studio Team Services with TFVC for source control. I've created an automated build, however, the build will fail (sporadically) with the following error:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (2015, 0)
The "ResolveComReference" task failed unexpectedly.
System.IO.IOException: The process cannot access the file 'C:\a\bin\es\System.Windows.Interactivity.resources.dll' because it is being used by another process.
Server stack trace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
at Microsoft.Build.Tasks.Copy.CopyFileWithLogging(FileState sourceFileState, FileState destinationFileState)
at Microsoft.Build.Tasks.Copy.DoCopyWithRetries(FileState sourceFileState, FileState destinationFileState, CopyFileWithState copyFile)
at Microsoft.Build.Tasks.NativeMethods.QueryPathOfRegTypeLib(Guid& clsid, Int16 majorVersion, Int16 minorVersion, Int32 lcid)
at Microsoft.Build.Tasks.ComReference.GetPathOfTypeLib(TaskLoggingHelper log, Boolean silent, TYPELIBATTR& typeLibAttr, String& typeLibPath)
at Microsoft.Build.Tasks.ResolveComReference.ConvertAttrReferencesToComReferenceInfo(List`1 projectRefs, ITaskItem[] typeLibAttrs)
at Microsoft.Build.Tasks.ResolveComReference.Execute()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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 Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()
When this does occur.. I can queue another build and it will pass. Does anyone know why this may be happening and how it can be fixed?

PermissionSet - Request Failed error

I have few projects communicating using ChannelSink, ServerSink and ClientSink.
I've upgraded the projects from .NET 2.0 to .NET 4.0. Before the upgrade everything worked fine.
Now, when I try to communicate , - for a specific message - my OnReceiveMessage isn't called and throwing the following exception:
System.Security.SecurityException: Request failed
Server stack trace:
at System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32*
pLowerBounds)
at System.Array.CreateInstance(Type elementType, Int32 Length)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseArray(ParseRecord
pr)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(ParseRecord
pr)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord
pr)
System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXML()
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Run()
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler,
ISerParser
serParser)
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream,
HeaderHandler handler)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream
inputStream, Header[] h, Boolean bStrictBinding)
at System.Runtime.Remoting.Chanels.SoapServerFormatterSink.ProcessMessage
(IServerChannelSinkStack sinkStack, IMessage requestMsg,
ITransportHeaders requestHeaders, Stream
requestStream, IMessage& responseMsg, ITransportHeaders&
responseHeaders, Stream& responseStream)
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)
.
. (some of my files)
. The action that failed was: Demand The type of the first permission that failed was: System.Security.PermissionSet The demand
was for:
The only permitted permissions were:
The method that caused that failure was:
System.Runtime.Remoting.Channels.ServerProcessing
ProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStack,
System.Runtime.Remoting.Messaging.IMessage,
System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream,
System.Runtime.Remoting.Messaging.IMessage ByRef,
System.Runtime.Remoting.Channels.ITransportHeaders ByRef,
System.IO.Stream ByRef)
The thing is, if I create a dummy method and add it to the sinkstack - it calls it. even if I use the same proxy which denies the message.
Other thing is, The other messages are working just fine. only one type of messages isnt working from all the types iv'e created.
I haven't requested PermissionSet at my app at all, Any help?
Pah - should have guess that 5 minutes after posting on stack exchange I would find it. I simply had to replace:
<formatter ref="soap" />
by
<formatter ref="soap" typeFilterLevel="Full" />
The MSDN documentation for typeFilterLevel explains what's happening, although I'm not entirely sure why an array isn't considered a "basic" type

WPF Designer Fails to Load

Using Visual Studio 2012 on Win7.
I recently converted a WPF application to a WPF user control by replacing the XAML flags <Window> with <UserControl> and changing the resources to <Control.Resources>. I also altered the codebehind to inherit from UserControl just to be safe, but at some point this broke the application and I can no longer view it in Design mode. All I get is this nonsense:
System.NullReferenceException
Object reference not set to an instance of an object.
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOut(Action action, Int32 targetApartmentId, WaitHandle aborted, CallSynchronizationMode syncMode, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CallSynchronizationMode syncMode)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TResult,TValue](RemoteHandle`1 targetObject, Func`2 func, CallSynchronizationMode syncMode)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CreateDesignerImpl(IHostSourceItem item, IHostTextEditor editor, RemoteCancellationToken remoteCancelToken)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass12.<Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner>b__11(RemoteCancellationToken remoteToken)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CallWithCancellation[TResult](CancellationToken cancelToken, Func`2 func)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken)
at Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
System.NullReferenceException
Object reference not set to an instance of an object.
Server stack trace:
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn[TResult](IRemoteObject targetObject, Func`1 func)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken remoteToken)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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 Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken cancelToken)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass8.<CreateDesignerImpl>b__6(IRemoteDesignerService d)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass4`2.<MarshalOut>b__3()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
System.NullReferenceException
Object reference not set to an instance of an object.
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOut(Action action, Int32 targetApartmentId, WaitHandle aborted, CallSynchronizationMode syncMode, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CallSynchronizationMode syncMode)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TResult,TValue](RemoteHandle`1 targetObject, Func`2 func, CallSynchronizationMode syncMode)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalHostProjectService.Microsoft.Expression.DesignHost.IHostProjectService.FindProject(FindProjectCriteria criteria, String criteriaValue)
at Microsoft.Expression.DesignSurface.Project.ProjectContextManager.FindApplicationProjectContext(XamlProjectContext requestingContext)
at Microsoft.Expression.DesignSurface.Project.XamlProjectContext.get_Application()
at Microsoft.Expression.DesignSurface.Documents.SceneDocument.GetApplicationDocument(IXamlProjectContext activeContext)
at Microsoft.Expression.DesignSurface.Documents.SceneDocument.get_ApplicationSceneDocument()
at Microsoft.Expression.DesignSurface.DocumentViewContext.CreateAndOpenView(ISourceItemContext sourceItem, CancellationToken cancelToken, Boolean activate, Boolean ensureOpenInHost, Boolean suppressUI)
at Microsoft.Expression.DesignSurface.DesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass10.<>c__DisplayClass12.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner>b__f(CancellationToken cancelToken)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.CallWithCancellation[TResult](IRemoteCancellationToken remoteToken, Func`2 func)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass10.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner>b__e()
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass16`1.<MarshalIn>b__15()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
System.NullReferenceException
Object reference not set to an instance of an object.
Server stack trace:
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn[TResult](IRemoteObject targetObject, Func`1 func)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteHostProjectService.Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteHostProjectService.FindProject(FindProjectCriteria criteria, String criteriaValue)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
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 Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteHostProjectService.FindProject(FindProjectCriteria criteria, String criteriaValue)
at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalHostProjectService.<>c__DisplayClass7.<Microsoft.Expression.DesignHost.IHostProjectService.FindProject>b__6(IRemoteHostProjectService ps)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass4`2.<MarshalOut>b__3()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
System.NullReferenceException
Object reference not set to an instance of an object.
at MS.Internal.VSUtilities.GetBuildAction(IVsHierarchy hierarchy, UInt32 itemid)
at Microsoft.VisualStudio.ExpressionHost.HostServices.HostSourceItem.<>c__DisplayClass9.<Microsoft.Expression.DesignHost.IHostSourceItem.get_BuildItemType>b__7()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.Invoke(Boolean waitingInExternalCall)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.InvokeCall(Call call)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.DirectInvoke(Action action, Int32 sourceApartmentId, Int32 targetApartmentId, Int32 originId, WaitHandle aborted)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.DirectInvokeInbound(Action action, Int32 targetApartmentId)
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId)
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action)
at Microsoft.VisualStudio.ExpressionHost.HostServices.HostSourceItem.Microsoft.Expression.DesignHost.IHostSourceItem.get_BuildItemType()
at Microsoft.Expression.HostUtility.Extensions.HostExtensions.<HasApplicationDocument>b__0(IHostSourceItem i)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Microsoft.Expression.HostUtility.Extensions.HostExtensions.HasApplicationDocument(IHostProject hostProject)
at Microsoft.VisualStudio.ExpressionHost.HostServices.HostProjectService.FindApplicationProject(String projectPath)
at Microsoft.VisualStudio.ExpressionHost.HostServices.HostProjectService.<FindProjectsInternal>d__30.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Microsoft.VisualStudio.ExpressionHost.HostServices.HostProjectService.Microsoft.Expression.DesignHost.IHostProjectService.FindProject(FindProjectCriteria criteria, String criteriaValue)
at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteHostProjectService.<>c__DisplayClass1d.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteHostProjectService.FindProject>b__1c()
at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass16`1.<MarshalIn>b__15()
at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
After several googlings I located that this was a hot issue in 2012 but seems to have all but evaporated since then. But now I have nothing to go on! All my assemblies are 3.5+ (2.0 assemblies being a known issue back then) and I tried removing references but that didn't help either. I've made almost no code changes except instantiating an IoC in the control's load, but I also removed that code completely to no avail.
Anyone have any experience with this issue?
Edit - Please note, if I add a new UserControl with absolutely no customization and attempt to view it I get the same error.
Edit 2 - Tried "Attach to Process", it didn't do anything when I tried to reload the designer.
It's the bug of Visual Studio in creating incorrect intermediate files. Only rebuilding all projects may not solve the problem.
Try this,
Close the Visual Studio.
Delete the 'obj' folder.
Reopen Visual Studio.
Rebuild all projects.
Good luck !
One of the reason may be a binding of some your static resource to object which is temporary null
It may be for example binding to RowData.Row.Property where row is current row of another resource, which is null in Design Time.
The better way is Binding to RowData.Row which with Converter
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (value is MyContentType)
{
return (value as MyContentType).Property
}
else
{
return defaultValue // this value is valid for wpf control property
}
}
Other reason may be that some of your Converters or TemplateSelectors doesn't check incoming value for null
May be something else but i have no idea ....
Finally figured it out after noticing my other coworkers could see the control just fine.
The answer in this case appears to be that my visual studio was still at first release and required an update to version 4. So if all else fails and someone else runs into this issue, download the most recent visual studio patch and kick it off. I'm sure when it's done installing in a little while it'll work again.

"Value cannot be null" when invoking method decorated with [Autocomplete]

I have a Windows Forms application (.NET 3.5) which is deployed with the ClickOnce-technology and is used by approximately 50-100 concurrent users. They all target the same MS SQL database (SQL SERVER 2008 R2) which is hosted externally.
The application itself uses a "wrapper"-class to perform database queries. This class derives from ServicedComponent and decorates its methods with the [AutoComplete] attribute. Below is an example:
[Serializable]
[Transaction(TransactionOption.Required, Isolation=TransactionIsolationLevel.ReadCommitted)]
public class CTxGreenfee374Processor: ServicedComponent
{
public CTxGreenfee374Processor() { }
[AutoComplete]
internal Season SaveSeason(CallContext callContext, Season season)
{
return new PGreenfee374Processor().SaveSeason(callContext, season);
}
}
Most of the time this approach works like a charm. But numerous times a day following exception occur when this method gets invoked (of course there are similar methods with this exact problem):
System.ArgumentNullException
Value cannot be null.
Server stack trace:
at System.Threading.Monitor.Enter(Object obj)
at System.Data.ProviderBase.DbConnectionPool.TransactedConnectionPool.TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
at System.Data.ProviderBase.DbConnectionPool.TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject)
at System.Data.ProviderBase.DbConnectionInternal.CleanupConnectionOnTransactionCompletion(Transaction transaction)
at System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment enlistment)
at System.Transactions.TransactionStateDelegatedCommitting.EnterState(InternalTransaction tx)
at System.Transactions.TransactionStateDelegated.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
at System.Transactions.CommittableTransaction.Commit()
at System.EnterpriseServices.TransactionProxy.Commit(Guid guid)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.EnterpriseServices.Thunk.Callback.DoCallback(Object otp, IMessage msg, IntPtr ctx, Boolean fIsAutoDone, MemberInfo mb, Boolean bHasGit)
at System.EnterpriseServices.ServicedComponentProxy.CrossCtxInvoke(IMessage reqMsg)
at System.EnterpriseServices.ServicedComponentProxy.Invoke(IMessage request)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at GOLFIT.BusinessProcess.Economics.CTxGreenfee374Processor.SaveSeason(CallContext callContext, Season season)
at GOLFIT.BusinessProcess.Economics.Greenfee374Processor.SaveSeason(CallContext callContext, Season season) in C:\Projekt\GOLFIT\DEVELOPMENTPROD374\BusinessProcess\GOLFIT.BusinessProcess.Economics\Greenfee374\Greenfee374Processor.cs:line 104
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 GOLFIT.BusinessProcess.Economics.Greenfee374Processor.SaveSeason(CallContext callContext, Season season)
at GOLFIT.WinGUI.Economics.FrmPrice374.Save(Boolean refresh).
As you can see the method SaveSeason in the CTxGreenfee374Processor class is mentioned in the exception. As far as I can see this is the last trace of code that I've written.
My only clue is that the exception has something to do with the [AutoComplete] attribute and/or the derived ServicedComponent class. This conclusion is based on that I've checked for invalid input parameters and that no code inside the method gets executed before the exception. And I assume that both ServicedComponent class and [AutoComplete] attribute performs som kind of logic before the method block executes.
I haven't been successful in recreating this exception when debugging, due to inconsequent occurrences of this exeption. So I've had to depend on logs from the production application.
If anyone got an idea regarding this problem it would be extremely appreciated!

Categories

Resources