.NET 4 Deserialization issue: Illegal call to the reserved method - c#

On some, but not all, machines when we try to deserialize some XML using (written in C#) System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
we get a kind of security related error described in the error message and stack trace below. The exception is thrown by the assembly that gets generated by .NET when serializing/deserializing.
In the stack trace below, AggregateElement derives from Element.
We haven't had any problems with .NET 3.5 and our code hasn't changed since we've upgraded to .NET 4
Does anyone have any ideas on what and why this is?
Error: Illegal call to the reserved method 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read53_AggregateElement()' from 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read72_Element()'.
Call Stack Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read53_AggregateElement(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read72_Element(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read74_Section(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read70_SubForm(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read72_Element(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read74_Section(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read70_SubForm(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read92_Sheet(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSheet.Read93_Sheet()
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType 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.Xml.Serialization.TempAssembly.InvokeReader(XmlMapping mapping, XmlReader xmlReader, XmlDeserializationEvents events, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)

Related

Nunit 3.2.1 failing only when using console runner

I'm developing framework using c# and selenium. When I am using ReSharper to run my tests everything is working fine.
TCSA = TestCaseSource artibute
But I have strange problem with Nunit 3.2.1 console runner. I have 5 tests and each of them is using one of two TCSA. When I had about 3 tests everything was running fine. But when I add some more then Im getting error on that situation:
When 1st test finish with all TCSA, then 2nd test starts. On second TCSA of 2nd test, Nunit is failing before starting test with another TCSA:
1) Error :
Exception has been thrown by the target of an invocation.
Server stack trace:
w System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
w System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
w System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
w System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
w System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activatio
nAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
w System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationA
ttributes, Evidence securityInfo)
w System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationA
ttributes, Evidence securityAttributes)
w System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] ac
tivationAttributes, Evidence securityAttributes)
w System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] ac
tivationAttributes, Evidence securityAttributes)
w NUnit.Engine.Drivers.NUnit3FrameworkDriver.Run(ITestEventListener listener, String filter)
w NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
w System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
w System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
w System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
w System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
w NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
w NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)
Test Run Summary
Overall result: Failed
Test Count: 0, Passed: 0, Failed: 0, Inconclusive: 0, Skipped: 0
Start time: 2016-05-19 08:26:28Z
End time: 2016-05-19 08:32:11Z
Duration: 343,116 seconds
Does anyone know what is the source of this problem?

Error on local machine but not on production server

Can someone help me with this error ? this throws on 4 of 5 developer boxes and does not (fortunatelly) on production enviroment, yet no idea why.
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.OverflowException: Value was either too large or too small for
a Decimal. at System.Number.ParseDecimal(String value, NumberStyles
options, NumberFormatInfo numfmt) at System.Convert.ToDecimal(String
value, IFormatProvider provider) at
System.String.System.IConvertible.ToDecimal(IFormatProvider provider)
at System.Convert.ToDecimal(Object value) at
MySql.Data.MySqlClient.MySqlDataReader.GetDecimal(Int32 i) at
MySql.Data.Entity.EFMySqlDataReader.GetDecimal(Int32 ordinal) ---
End of inner exception stack trace --- at
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor) at
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader1.GetTypedValueDefault(DbDataReader
reader, Int32 ordinal) at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader1.GetValue(DbDataReader
reader, Int32 ordinal) at lambda_method(Closure , Shaper ) at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func2
constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
at lambda_method(Closure , Shaper ) at
System.Data.Entity.Core.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper
shaper) at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.RowNestedResultEnumerator.MaterializeRow()
at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.RowNestedResultEnumerator.MoveNext()
at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.ObjectQueryNestedEnumerator.TryReadToNextElement()
at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.ObjectQueryNestedEnumerator.ReadElement()
at
System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.ObjectQueryNestedEnumerator.MoveNext()
at System.Data.Entity.Internal.LazyEnumerator1.MoveNext() at
System.Collections.Generic.List1..ctor(IEnumerable1 collection) at
System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at
Glocalapps.BusinessLogic.Logic.ProductLogic.GetProductManagementCatalogData(Int32
idCatalog, Int32 skip, Int32 take, String name, Nullable1 isActive,
Nullable1 isVisible, Nullable1 revised)

Exception occurs when i try to create instance of type through assembly.CreateInstance method

Exception occurs when i try to create instance of type through assembly.CreateInstance method. This is my code in which exception occurs
Assembly assembly = Assembly.LoadFrom(#"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.UserProfiles.dll");
Type type = assembly.GetType("Microsoft.Office.Server.UserProfiles.UserProfileManager");
object ins = assembly.CreateInstance(type.FullName);
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: serviceContext
at Microsoft.Office.Server.UserProfiles.ProfileManagerBase..ctor(SPServiceContext serviceContext)
at Microsoft.Office.Server.UserProfiles.ProfileManagerBase..ctor(SPServiceContext serviceContext, Boolean ignorePrivacy)
at Microsoft.Office.Server.UserProfiles.UserProfileManager..ctor(SPServiceContext serviceContext, Boolean IgnoreUserPrivacy, Boolean backwardCompatible)
at Microsoft.Office.Server.UserProfiles.UserProfileManager..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 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Reflection.Assembly.CreateInstance(String typeName)
at HomeWork.Program.Main(String[] args) in c:\users\amasud\documents\visual studio 2010\Projects\HomeWork\HomeWork\Program.cs:line 23
I dont know the reason why you want to create Microsoft.Office.Server.UserProfiles.UserProfileManager object in reflective way. In your case, you have to pass SPServerContext to the constructor. Here is how you can do it.
Assembly assembly = Assembly.LoadFrom(#"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.UserProfiles.dll");
SPServiceContext serviceContext = SPServiceContext.Current;
Type type = assembly.GetType("Microsoft.Office.Server.UserProfiles.UserProfileManager");
object ins = Activator.CreateInstance(type, serviceContext);
From the look of it, whatever type you are creating is expecting a serviceContext parameter in the constructor. You haven't set it, so it crashes.

WPF Application Ribbon crash

I created a program in visual studio 2008 with multiple windows. One of the windows uses the windows ribbon control. Now the program works fine on my computer (windows XP) but when I want to run it on another computer fresh installed with .net 3.5 SP1 installed I can start the program but I get a crash when I open the window with the ribbon control.
This is the error file I get when I do try catch:
System.Windows.Markup.XamlParseException: Exception has been thrown
by the target of an invocation. Error at object
'System.Windows.Data.Binding'. --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.ComponentModel.Win32Exception:
HRESULT_FROM_WIN32(ERROR_NOT_FOUND) at
Standard.HRESULT.ThrowIfFailed(String message) at
Standard.NativeMethods.GetCurrentThemeName(String& themeFileName,
String& color, String& size) at
Microsoft.Windows.Shell.SystemParameters2._InitializeThemeInfo() at
Microsoft.Windows.Shell.SystemParameters2..ctor() at
Microsoft.Windows.Shell.SystemParameters2.get_Current() --- End of
inner exception 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.GetValue(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo
culture) at System.Reflection.RuntimePropertyInfo.GetValue(Object
obj, Object[] index) at
System.Windows.Markup.StaticExtension.ProvideValue(IServiceProvider
serviceProvider) at
System.Windows.Markup.BamlRecordReader.GetStaticExtensionValue(Int16
memberId) at
System.Windows.Markup.BamlRecordReader.GetExtensionValue(IOptimizedMarkupExtension
optimizedMarkupExtensionRecord, String propertyName) at
System.Windows.Markup.TemplateBamlRecordReader.ReadPropertyWithExtensionRecord(BamlPropertyWithExtensionRecord
bamlPropertyRecord) at
System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord
bamlRecord) --- End of inner exception stack trace --- at
System.Windows.Markup.XamlParseException.ThrowException(String
message, Exception innerException, Int32 lineNumber, Int32
linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds,
XamlObjectIds contextXamlObjectIds, Type objectType) at
System.Windows.Markup.XamlParseException.ThrowException(ParserContext
parserContext, Int32 lineNumber, Int32 linePosition, String message,
Exception innerException) at
System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord
bamlRecord) at
System.Windows.Markup.TemplateBamlRecordReader.ReadNonContentRecord(BamlRecord
bamlRecord) at
System.Windows.Markup.TemplateBamlRecordReader.ReadRecord(BamlRecord
bamlRecord) at System.Windows.Markup.BamlRecordReader.Read(Boolean
singleRecord) at
System.Windows.Markup.TemplateTreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse() at
System.Windows.Markup.XamlTemplateSerializer.ConvertBamlToObject(BamlRecordReader
reader, BamlRecord bamlRecord, ParserContext context) at
System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord
bamlElementRecord) at
System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord
bamlRecord) at
System.Windows.Markup.BamlRecordReader.ReadElement(Int64
startPosition, XamlObjectIds contextXamlObjectIds, Object
dictionaryKey) at
System.Windows.ResourceDictionary.CreateObject(Int32 valuePosition,
Object key) at
System.Windows.ResourceDictionary.RealizeDeferContent(Object key,
Object& value, Boolean& canCache) at
System.Windows.ResourceDictionary.GetValueWithoutLock(Object key,
Boolean& canCache) at
System.Windows.ResourceDictionary.GetValue(Object key, Boolean&
canCache) at
System.Windows.DeferredThemeResourceReference.GetValue(BaseValueSourceInternal
valueSource) at
System.Windows.DependencyPropertyChangedEventArgs.get_NewValue() at
System.Windows.Controls.Control.OnTemplateChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e) at
System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs
e) at
System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs
e) at
System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs
args) at
System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex
entryIndex, DependencyProperty dp, PropertyMetadata metadata,
EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean
coerceWithDeferredReference, OperationType operationType) at
System.Windows.StyleHelper.ApplyStyleOrTemplateValue(FrameworkObject
fo, DependencyProperty dp) at
System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject
container, FrugalStructList1& exclusionContainerDependents,
FrugalStructList1& oldContainerDependents, FrugalStructList`1&
newContainerDependents) at
System.Windows.StyleHelper.DoThemeStyleInvalidations(FrameworkElement
fe, FrameworkContentElement fce, Style oldThemeStyle, Style
newThemeStyle, Style style) at
System.Windows.StyleHelper.UpdateThemeStyleCache(FrameworkElement fe,
FrameworkContentElement fce, Style oldThemeStyle, Style newThemeStyle,
Style& themeStyleCache) at
System.Windows.FrameworkElement.OnThemeStyleChanged(DependencyObject
d, Object oldValue, Object newValue) at
System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe,
FrameworkContentElement fce) at
System.Windows.FrameworkElement.UpdateThemeStyleProperty() at
System.Windows.FrameworkElement.OnInitialized(EventArgs e) at
System.Windows.Controls.MenuItem.OnInitialized(EventArgs e) at
System.Windows.FrameworkElement.TryFireInitialized() at
System.Windows.FrameworkElement.EndInit() at
System.Windows.Controls.ItemsControl.EndInit() at
System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
at System.Windows.Markup.BamlRecordReader.ReadElementEndRecord(Boolean
fromNestedBamlRecordReader) at
System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord
bamlRecord) at System.Windows.Markup.BamlRecordReader.Read(Boolean
singleRecord) at
System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment() at
System.Windows.Markup.TreeBuilder.Parse() at
System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext
parserContext, Object parent, Boolean closeStream) at
System.Windows.Application.LoadComponent(Object component, Uri
resourceLocator) at
Waak.WeegschaalProgramma.WeegAuteurWindow.InitializeComponent() at
Waak.WeegschaalProgramma.WeegAuteurWindow..ctor(WeegschaalProcessor
weegschaalProcessor)
Anybody has seen this error before or has any tips to help me out? I already removed .net and completely reinstalled it.
Your exception is a bit different than the one I had (XamlParseException Provide value on 'System.Windows.Markup.StaticExtension' threw an exception.) but I think you should take a look at my answer here

MMC development in c#

Hi i am developing MMC snap in C#,
in this i want to read XML file so where to put my xml file.
the code is not giving any build error but when i am adding the snapin in MMC its giveing error what to do.
[SnapInSettings("{2078B103-76FF-46E1-95BB-8B2CE3A72E60}",
DisplayName = "Configuration",
Description = "abc Pvt Ltd.")
]
public class Mymmc : SnapIn
{
XDocument xDoc;
public Sararmmc()
{
ScopeNode childscopenode;
xDoc = XDocument.Load("MMCSnapinXML.xml");
IEnumerable<XElement> xelements = xDoc.Root.Descendants();
this.RootNode = new ScopeNode();
this.RootNode.DisplayName = xDoc.Root.Attribute("name").Value;
foreach (XElement elm in xelements)
{
childscopenode = new ScopeNode();
childscopenode.DisplayName = elm.Attribute("name").Value;
this.RootNode.Children.Add(childscopenode);
}
}
}
i am getting
Exception has been thrown by the target of an invocation.
Server stack trace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at Microsoft.ManagementConsole.Internal.SnapInClient.CreateSnapIn(String assemblyName, String typeName)
at Microsoft.ManagementConsole.Internal.ClassLibraryServices.Microsoft.ManagementConsole.Internal.IClassLibraryServices.CreateSnapIn(String assemblyName, String typeName)
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 Microsoft.ManagementConsole.Executive.SnapInInitializationOperation.OnStart()
at Microsoft.ManagementConsole.Executive.Operation.Start()
at Microsoft.ManagementConsole.Executive.RunningOperationsTable.EnqueueOperation(Operation operation)
at Microsoft.ManagementConsole.Executive.StandAloneComponentData..ctor(SnapInRegistrationInfo info, Int32 bookkeepingId)
at Microsoft.ManagementConsole.Advanced.FrameworkSnapInFactory.Microsoft.ManagementConsole.Advanced.ISnapInFactory.CreateSnapIn(Int32 bookkeepingId, String snapInKey, Object& snapIn)
There are many exceptions which could be thrown in your constructor (the stack trace indicates that this is the source of the error). It could be a malformed XML exception is thrown on XDocument.Load, it could also be null reference exception if any of the named nodes/attributes you're accessing don't exist. It could be a file not found exception, or even a SecurityException - it could even be something more obscure such as MMC requiring that your assembly is signed.. without knowing what type of exception you're getting it's very difficult for anyone to help you!
As I said in my comment, when you receive errors at runtime that you can't easily explain - this is when having verbose logging in your application becomes really valuable! NLog and log4net are the two most popular logging frameworks for .NET applications

Categories