I have an existing MVC 4 application that uses the AspNetSqlProfileProvider, configured like this:
<properties>
<add name="MyTypeAs"
type="System.Collections.Generic.List`1[[My.Namespace.MyTypeA, My.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" serializeAs="Binary" />
</properties>
Now I wish to update the system (without removing the old profiles) like this:
<properties>
<add name="MyTypeAs"
type="System.Collections.Generic.List`1[[My.Namespace.MyTypeA, My.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" serializeAs="Binary" />
<add name="MyHashOfInts"
type="System.Collections.Generic.HashSet`1[System.Int32]" serializeAs="Binary" />
</properties>
I have had no problem adding additional properties in previous projects. If the serialized data was from a previous version where the additional property was not defined, loading that property
yielded default(T). However, with this change, when my controller executes this line:
List<MyTypeA> myTypeAs =
(List<MyTypeA>)HttpContext.Current.Profile.GetPropertyValue("MyTypeA");
an Exception is thrown:
Attempting to load this property's type resulted in the following error: Could not load type 'System.Collections.Generic.HashSet`1[System.Int32]'.
Notice that I'm referencing a property of type List<MyTypeA> but the Exception says it cannot load the type
System.Collections.Generic.HashSet`1[System.Int32].
Did I make a mistake in how I specified the type in web.config? Is there another cause?
All of this is happening in Visual Studio 2010 SP1 with the .NET 4 runtime selected.
It turns out that, different from List<T>, HashSet<T> requires a fully qualified assembly name.
System.Collections.Generic.HashSet`1[[System.Int32]], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Related
I have a Windows service application made with VB.NET under Visual Studio 2013 and using NET Framework 4.5. I am using Nuget in this project.
Once I build the solution (it builds successfully) I get below warning messages in the results window:
No way to resolve conflict between "Microsoft.ReportViewer.ProcessingObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.ProcessingObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Microsoft.ReportViewer.DataVisualization, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.DataVisualization, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.DataVisualization, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from version "9.0.0.0" [] to version "11.0.0.0" [C:\MyProjects\WindowsServices\MyService\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3276: Microsoft.Common.CurrentVersion.targets Found conflicts between different versions of the same dependent assembly.
Please set the "AutoGenerateBindingRedirects" property to true in the project file. For further information, see http://go.microsoft.com/fwlink/?LinkId=294190.
I have been searching for information about this, and I have found some posts and blogs talking about that:
No Way to Resolve Conflict Between dlls
No Way to Resolve Conflict Between dlls
I have tried to clean up all the references in the VB.NET project that were not being used but above warning messages continue appearing.
Also I have gone into Manage NuGet Packages but I have not seen any duplicate packages in the list.
I don't see the duplicates anywhere (vbproj project file, app.config, etc.). Where can I find those duplicates? Where are the duplicates? How to search for the duplicates?
Finally, I know there is another way to resolve those conflicts (I have not tried yet) and it consists on adding binding redirects for all the assemblies that are conflicted in the app.config file. For example, in case of ClosedXML DLL:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ClosedXML" publicKeyToken="fd1eb21b62ae805b" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.85.0.0" newVersion="0.85.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Instead of adding manually confliting assemblies in the app.config file, I know it can be done automatically by Visual Studio by adding the property entry below in the vbproj project file:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
as explained here.
Anyway, I would like to resolve those conflicts without binding redirects for all the conflicted assemblies in the app.config file. So Is that possible? If so, how?
Also I have some other questions in mind:
Binding redirects for conflicted assemblies in the app.config file
is a good practice?
Why those conflicts between assemblies happen? I do not understand it at all, so please could you explain me this?
What happens if I not resolve those conflicts and I ignore them (since solution is build successfully without errors)? Is it mandatory or highly recomended to resolve them for any kind of reason that I currently do not know?
I have an NServiceBus endpoint configured to UseNHibernateTimeoutPersister.
I use EL 5 for logging:
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
I also added a reference in the project to the NServiceBus.Core.
Why do I get the following CodeAnalysis warning:
Warning 36 CA0060 : The indirectly-referenced assembly 'Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. This assembly was referenced by: c:\NServicebus3.3.2\NServiceBus.NHibernate.dll.
You need to add a reference to Common.Logging v2, you can get that from nuget using the following:
PM> Install-Package Common.Logging -Version 2.0
I'm getting stuck with the above mentioned error. I have successfully deployed the webpart in 3 different ways, throgh stsadm, through Powershell (add-spsolution, install-spsolution) and via Central Administration.
The Webpart is .wsp which ran without any problems in Sharepoint 2007. I have changed the <safe control>entries in the web.config.
<SafeControl Assembly="TimeRecordingWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="TimeRecordingWP" TypeName="*" Safe="True" AllowRemoteDesigner="True" SafeAgainstScript="true" />
<SafeControl Assembly="TimeRecordingWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="TimeRecordingWP.Controls" TypeName="*" Safe="True" AllowRemoteDesigner="True" SafeAgainstScript="true" />
<SafeControl Assembly="TimeRecordingWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="TimeRecordingWP.Util" TypeName="*" Safe="True" AllowRemoteDesigner="True" SafeAgainstScript="true" />
<SafeControl Assembly="TimeRecordingWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="TimeRecordingWP.Dao" TypeName="*" Safe="True" AllowRemoteDesigner="True" SafeAgainstScript="true" />
I have changed the <trust>parameter to Full but no success. Neither the Preview in Webpartcatalog->all webparts nor the webpart will work showing the message named in the title of this post.
I'm pretty lost.
Thank's in advance..
I managed to fix the problem.
My case was:
Created new Visual Web Part with Visual Studio 2010
Copied some stuff from similar project
Renamed some properties to project-specific names
Got this error when tried to add the webpart to a page.
Thing that fixed my issue:
Changed Namespace value of SafeControl in SharePointProjectItem.spdata (hidden file) to match the actual namespace I was using
Hope this helps :)
Rene.
I gave some thoughts to the same matter few days ago. The problem was happened when I created not an empty project and rename some properties in it to more sensible.
Unfortunately, I couldn't find the reason of this problem. But I resolved it by creating an empty sharepoint project and adding the necessary items in it.
I created a "Hello World" Sharepoint 2010 solution using VS2010. It contains just a feature, and a webpart containing a label. I registered the webpart as a safe control in the "Properties" window of the webpart, in VS2010.
When I deploy my solution to my local server, everything works great! I can add the webpart to a page, and in the web.config file my control is added to the SafeControls list. When I install the same solution on a different server, I can see the webpart in the list of available webparts, but when I try to add it to the page, it tells me that it's not registered as safe. When I check the web.config file, there is no entry for my control. If I add one manually (the one from my dev server), things start to work.
Now, I wonder why the control is not registered when I install the wsp file. The manifest inside the wsp contains this line:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440" Namespace="abc.TestWebPart.VisualWebPart1" TypeName="*" />
</SafeControls>
</Assembly>
Any ideas are very welcomed!
Check for typos and version differences.
Did you activate the feature for the web app?
Late answer I know.
I think you are missing ' Safe="TRUE" ' in your SafeControl Tag.
Correct code:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl
Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440"
Namespace="abc.TestWebPart.VisualWebPart1"
TypeName="*"
Safe="TRUE"
/>
</SafeControls>
</Assembly>
</Assemblies>
I am developing WCF service hosted by IIS. I need to add KnownType attribute to my base class. One way of adding KnownType attribute is to add a section into the Web.config file like this:
<system.runtime.serialization>
<dataContractSerializer>
<declaredTypes>
<add type="MyBase, MyBaseDll">
<knownType type="MyDerived, MyDerivedDll"/>
</add>
</declaredTypes>
</dataContractSerializer>
</system.runtime.serialization>
But I got error message when my mouse is over the MyBase. The Error message is “Invalid Module Qualification: Failed to resolving assembly MyBaseDll”. Same error message for MyDerivedDll.
Additional information:
Both MyBaseDLL.dll and MyDerivedDLL.dll are in the IIS /bin folder. Both DLLs reference no other assembly other than .net system assemblies
Have you tried giving the full name of the assemblies and full name of the types (namespaces and all) ...
<add type="MyNamespace.MyBase,
MyBaseDLL, Version=v.v.v.v, Culture=neutral,
PublicKeyToken=XXXXXX">
<knownType type="MyNamespace.MyDerived,
MyDerivedDLL, Version=v.v.v.v, Culture=neutral,
PublicKeyToken=XXXXXX"/>
</add>
What happens when you run the service? The error message could be bogus. For instance, ReSharper sometimes gets confused about assembly references in config files.
OTOH, other times, it's correct.