Problem with conversion of existing project to Silverlight 4 - silverlight-4.0

We have a working Silverlight 3 project. After changing the target framework to Silverlight 4 the application won't start anymore. It throws an exception in the following line in the generated InitializeComponent() method:
System.Windows.Application.LoadComponent(this, new System.Uri("/SLAppMain;component/App.xaml", System.UriKind.Relative));
Here is the exception (note the inner exception):
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
bei System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
InnerException: System.TypeLoadException
Message=Der Typ 'System.Security.AllowPartiallyTrustedCallersAttribute' konnte nicht aus der mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e -Assembly geladen werden.
StackTrace:
bei System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
bei System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
bei System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
bei System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
bei System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
bei System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
bei System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
bei MS.Internal.XamlSchemaContext.ProcessXmlnsDefinitions(Assembly assembly, String assemblyName)
bei MS.Internal.XamlSchemaContext.EnsureManagedAssemblyAttributesLoaded()
InnerException:
The problem is that the type System.Security.AllowPartiallyTrustedCallersAttribute is not contained in the Silverlight version of mscorlib.dll.
I have no idea how to fix this nor where to look for causes. Has anyone encountered this problem? What could possibly cause this error?

the AllowPartiallyTrustedCallersAttribute class does not exist in SL 4 (neither in mscorlib, nor anywhere else) and did not exist in SL 3 either.
So there must be more than just the conversion from SL 3 to SL 4 to this I guess - is AllowPartiallyTrustedCallersAttribute used in your code somewhere?
Cheers, Alex
EDIT: Actually, you might want to take a look into your app's AssemblyInfo.cs (in the Properties folder). Perhaps the attribute is used there like
[assembly: AllowPartiallyTrustedCallers(true)]
. You could then simply remove it and see what happens...

Do you use Unity for silverlight in your project ? I had exactly the same problem yesterday, and the error disappeared when I de-referenced unity

This walk through REALLY helped me with the same issue http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=5122

Doing a clean build followed by a full rebuild fixed this issue for me.

Dependencies with the same name will be quietly overwritten and packaged into a XAP after the compilation, so make sure that different target platforms of your projects don't build into the same output folder.

Related

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8007007f

I have a message error when I run my software application and that I open a window that is using EXCEL in the background.
This is the detail message error that I get :
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x8007007F): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following
error: 8007007f La procédure spécifiée est introuvable. (Exception from HRESULT: 0x8007007F).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType
objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType
serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType
serverType, Object[] props, Boolean bNewObj)
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, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at WindowsApplication1.Aux_Publiques.Detection_Fichier_OTIF_Fournisseurs()
at WindowsApplication1.frm_OTIF.frm_OTIF_Disposed(Object sender, EventArgs e)
at System.ComponentModel.Component.Dispose(Boolean disposing)
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at WindowsApplication1.frm_OTIF.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Form.WmClose(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)
'----------------------------------------------
I have tried this solution already :
Here
Anybody has an idea ?
I will remain at your disposal to answer questions
Thanks you.

Exception has been thrown by the target of an invocation - vb.net

I have an issue where I am receiving the error, "Exception has been thrown by the target of an invocation. I have the new keyword in place. I made sure the ReportsData_Employee.COATSEndAssignmentDataTable existed.
Imports System.Windows.Forms
Imports Advance.Extensions.Reporting
Imports CrystalDecisions.Shared
Imports Advance.Common.Reporting
Imports System.IO
Public Class Activity_EndAssignmentTool
ReadOnly _dt As New DataTable
Dim _dts As New DataTable
Dim _bldts As New DataTable
Dim _xml_file_name_creation As String
'// This is the line that is causing the error ============
ReadOnly _xml_datatable As ReportsData_Employee.COATSEndAssignmentDataTable = New ReportsData_Employee.COATSEndAssignmentDataTable()
'//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
======================================================================================
System.Reflection.TargetInvocationException was caught
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
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, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
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 Advance.Extensions.Activities.Activity_Form.GetActivityForm(String className) in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Forms\Activity_Form.vb:line 126
at Advance.Extensions.Activities.Activity_Form.SetActivityClass() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Forms\Activity_Form.vb:line 60
InnerException: System.NullReferenceException
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Advance.Extensions.Activities
StackTrace:
at Advance.Extensions.Activities.Activity_EndAssignmentTool.InitializeComponent() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.Designer.vb:line 479
at Advance.Extensions.Activities.Activity_EndAssignmentTool..ctor() in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.vb:line 12
InnerException:
Can someone name some other reasons why I could be getting this error? I have looked at multiple links but a lot of the answers don't apply in my situation.
"Exception has been thrown by the target of an invocation" error (mscorlib)
FYI I have tried ReadOnly _xml_datatable as New ReportsData_Employee.COATSEndASsignmentDataTable() and there was still an issue.
Any help is appreciated. Let me know if there is any other information you need.
Thanks.
You haven't initialized object properly. Here...
ReadOnly _xml_datatable As ReportsData_Employee.COATSEndAssignmentDataTable = New ReportsData_Employee.COATSEndAssignmentDataTable()
Should be
Private ReadOnly _xml_datatable As New ReportsData_Employee.COATSEndAssignmentDataTable()
Your real issue is
InnerException: System.NullReferenceException
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Advance.Extensions.Activities
You need to look into constructor of COATSEndAssignmentDataTable. you have NullReferenceException in there. These two lines tell you exact location
at Advance.Extensions.Activities.Activity_EndAssignmentTool.InitializeComponent()
in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.Designer.vb:line 479
at Advance.Extensions.Activities.Activity_EndAssignmentTool..ctor()
in C:\Users\JJanssen\Documents\Visual Studio 2010\Projects\Legacy\Advance Extensions\advance.extensions.activities\Activity_Forms\Activity_EndAssignmentTool.vb:line 12

Ninject not proving params to my Controller, after doing mass update with NuGet

I have an MVC4 project in which I use Ninject. I just use the Ninject MVC3-provided NinjectWebCommon.cs file, in the App_Start folder. I just performed a mass dependency update, with NuGet, without realizing how much trouble it might cause. It broke my Ninject setup, somehow. Prior to running the NuGet update, Ninject would properly create my controllers and provide them with the required constructor params. Now, after the update, I get the following error:
[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 'Portal.Web.Controllers.MatterController'. 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) +157
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
The code inside of the NinjectWebCommon.cs file is being executed still, though. I can place breakpoints on it, and watch it apply my bindings. I don't think MVC is using it when creating controllers anymore, though.
Does anybody have any idea what might have been broken by this NuGet update?

CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created

I'm trying to run an Excel 2007 VSTO 3.0 addin we've created. However since installing the ION Trading MarketView Excel Plug-in our add-in no longer seems to load properly and fails with the following error:
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
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 System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.LoadMafPipeline(AppDomain newDomain, IntPtr hostServiceProvider, AddInInformation info, EntryPoints requestedEntryPoints, OfficeApp officeApplication, OfficeVersion officeVersion, IntPtr& executor)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.CreateCustomizationDomainInternal(String solutionLocation, String manifestName, String documentName, Boolean showUIDuringDeployment, IntPtr hostServiceProvider, IntPtr& executor)
--- End of inner exception stack trace ---
Does anyone have any idea what could be causing this? Any pointers for how I could investigate further?
Thanks,
Tom
Here are some tips you may find on web, in order to fix the problem:
Reinstall VSTOR
Disable other add-ins
Install framework 3.5 sp1
Fix error in the security configuration on the computer that is running the Visual Studio Tools for Office solution
Modify/Disable custom rule of a company's virus software, blocking the .net framework ability to create the 'shadow copy' version of the vsto .dll.
Turn on .NET programmability support http://sqlblog.com/blogs/davide_mauri/archive/2010/07/30/powerpivot-not-visibile-in-excel.aspx
Move the entire solution to .NET 4.0

NHibernate Not Compile on my Window Server

My Apps was developed with NHibernate Working fine on my system but giving this error on the host Server
Index was outside the bounds of the array.
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.IndexOutOfRangeException: Index was outside the bounds of the array.
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:
[IndexOutOfRangeException: Index was outside the bounds of the array.]
NHibernate.Dialect.Dialect.IsQuoted(String name) +84
NHibernate.Dialect.Dialect.QuoteForSchemaName(String schemaName) +20
NHibernate.Cfg.HbmBinder.MakeIdentifier(XmlNode node, SimpleValue model, Mappings mappings) +228
NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings) +1223
NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings) +398
NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name) +69
[MappingException: Could not compile the mapping document: CMS.Common.Mapping.CMS.Common.Data.AccountPeriod.hbm.xml]
NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) +40
NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name) +137
NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name) +29
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) +109
NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) +185
NHibernate.Cfg.Configuration.AddResources(Assembly assembly, IList resources, Boolean skipOrdering) +166
NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering) +32
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +150
NHibernate.Cfg.Configuration.DoConfigure(XmlDocument doc) +644
NHibernate.Cfg.Configuration.Configure(XmlTextReader reader) +304
NHibernate.Cfg.Configuration.Configure(XmlNode node) +81
NHibernate.Cfg.Configuration.Configure() +35
ProjectBase.Data.NHibernateSessionManager.InitSessionFactory() +60
ProjectBase.Data.NHibernateSessionManager..ctor() +39
ProjectBase.Data.Nested..cctor() +39
[TypeInitializationException: The type initializer for 'Nested' threw an exception.]
ProjectBase.Data.NHibernateSessionManager.get_Instance() +38
CMS.Facade.CoreSystem.BuildSession() in C:\Users\Oladapo\Documents\Visual Studio 2008\Projects\Property Manager\CMS.Facade\CoreSystem.cs:440
CMS.Facade.AdvertSystem.RetrieveAllAdvert() in C:\Users\Oladapo\Documents\Visual Studio 2008\Projects\Property Manager\CMS.Facade\AdvertSystem.cs:16
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +350
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +488
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1247
System.Web.UI.WebControls.BaseDataList.GetData() +38
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +153
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54
System.Web.UI.WebControls.BaseDataList.DataBind() +55
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
After adding some NHibernate goodness to a project, I had similar problems deploying because I forgot to update the web.config file on production. Once I defined the hibernate-configuration section, everything worked.
Also happened to me when I had an empty enum defined.
That you have a MappingException included in your stack trace is key. This implies either a problem with your class mappings, or your NHibernate configuration. It could also be that your database does not contain tables or fields defined in your class mappings.
To be more specific, you would need to provide additional information.