Common Library in Sandbox Solution SharePoint 2013 - c#

We have a solution structure like:
Project 1 (Sandbox)
Project 2 (Farm)
Project 3 (Common Library, dll)
Both Project 1 and Project 2 are using the Project 3 output dll for some functionality.
Everything was working fine on SharePoint 2010 with .NET 3.5 (every project).
Now we have to migrate to SharePoint 2013 means we have to compile now with .NET 4.5 and its new Security Level (no more CAS etc.)
The problem is that the Sandboxed Solution can not activate its feature because of errors like:
"Namespace.Method" is security transparent, but is a member of a security critical type.
Is it not possible to use a common library in sandboxed solution anymore?
I tried to use the SecuritySafeCritical / SecurityCritical / AllowPartiallyTrust attributes and features but no combination could resolve the problem.
(No more CAS in 4.5)

In the assemplyInfo.cs file add the line:
[assembly: AllowPartiallyTrustedCallers]
Deploy the Sandbox solution and then the Farm solution. Since both are referring your dll, the farm will successfully update the dll.

Related

What Method of Shared Code Files Does Visual Studio/ReSharper Perform Better With?

Setup
VS Enterprise 15.7.6
ReSharper Ultimate 2018.1.3
I have to deploy .net Class Libraries without any expediencies on other dlls outside of the .net Framework and I'm trying to figure out Visual Studio / ReSharper performance implications (the performance of the IDE itself, not the compiled/deployed code) for sharing code files.
My solution has 23 .net 4.5.2 class library projects, and 1 shared project. This shared project is unique to this client. I also have shared code that is not unique to the client that is shared as a source only nuget package. This means the same code is added to every project and checked into TFS under every project.
Question
Would Visual Studio / ReSharper have better performance if I removed all the source only NuGet files, and added all of these files to the Shared Project?
Currently VS spends a lot of CPUs each time I type a keystroke, and I'm wondering if this change would help. Only Negative is that any upgrade of the Source Only Nuget Package would be manual...
Update 1 Added PrefView

Sharing a DLL between projects

Microsoft says it's platform neutral these days, so I'm trying to build on Mac and Linux only with VS Code and deploy to Azure. Why? It's mainly to prove that I can.
Our project has several parts which include a couple of different websites, a Web API, er API and a few other bits. On my Mac I've built a .Net Core Class Library with a load of objects in. Command line, dotnet build, DLL out, no problem.
I want to put that DLL on the Linux machine where the MVC website is being built - the objects forming the models part of that site hopefully. I cannot figure out how to get the website project to reference my DLL and use the objects.
I had assumed I copy it to the other machine, place it in the bin folder of the site being developed and reference it in the Dependencies section of the site's project.json. Nope. I saw a few articles that said .Net Core only works with NuGet and it had to be a package. Is that really true?
I've found and read (if not entirely understood) everything you could imagine on sharing between .net core and .net framework. This is a core-only project so not applicable. Frankly I'm lost, and something called .Net Standard has just rolled into my field of vision.
So instead of copying the DLL, use dotnet pack to build a nuget package on your Mac, and copy that to your Linux machine instead. Put it in a directory that you configure as a local nuget repository (no server or anything required) and you're away.
I agree it's not as straightforward as a reference to a DLL, but it's not too bad. Note that you'll need to version the package appropriately, so that the tool system can detect when it's changed.

IIS local, 2 websites, 2 application pool and "shared" dll problems

We developped 2 differents applications with visual studio 2013 :
The first for the front-end in C# .net mvc5
The second for a web service in C# .net WebApi 2
Both applications use newtonsoft.json nuget but with different versions (6.0.8 for front and 8.0.2 for web api).
We use Local IIS to test and debug.
In IIS we create 2 websites, and 2 separate application pool.
If i compile the the web service after front end, everything is fine.
If i compile the front end after the web service, the web service crash with the 6.0.8 version of newtonsoft.json ! Why ?
The application pools shared some dlls ?
I found some articles with the "Specific version" option of the reference in the projects. With the "specific version" at true, both version can run in parallel. But i don't want to do that.
I can also update the nuget to have the same version in both projects but it is a workaround, the problem could still there with another dlls.
I need to understand why with 2 applications pool share dlls (with différents versions)...
So do you have an idea :-) ?
Thanks
Whiletrue
Following from your comment - the reason is quite simple now. your webapi and mvc project both depend on classlib which depends on newtonsoft specific version. so when you build any of webapi or mvc project, classlib's dependencies are also added to webapi or mvc project. you can either break the dependency somehow or specify versions in the web config + project file explicitly and have both versions in your Bin folder.

How to resolve dll versioning in asp.net?

I am using asp.net web application.
I have one product where it dll named as opensp.dll. This application used the latest version of this app and it is 6.0.
There some class library modules which are used the reference of opensp.dll and it is older and it is 4.0. When I individual built these class library with 4.0 it is successfully built ,but it not allowed with the 6.0. No worries for not to built in 6.0.
but my problem is these class library's built dlls path to asp.net application(opensp.dll)'s bin directory. so when I run this web application it gives me error of some method not found of opensp.dll. so I have replace new version of opensp.dll 6.0, then every this works fine. my application and modules of class libraries.
So each time when I built dll of class library I have put copy of opensp.dll to bin . I made back up of opensp.dll somewhere else. I don't have code of opensp.dll.
Can you please suggest to overcome this copy paste and work smooth process?
check your
[assembly: AssemblyVersion("X.0.0.0")]
in assemblyinfo.cs of class library . Is it still 4.0.0.0 ? Also your question is a bit unclear so let me ask , are you planning on keeping both dlls ? If yes have a look at side-by-side execution of assebmlies :- https://msdn.microsoft.com/en-us/library/8477k21c(v=vs.110).aspx
You can strongly name both the assemblies and deploy in GAC , but it not recommended to do so as the GAC is a shared resource and is available to all the applications running in the framework .

How to know what are the prerequisites for my windows form application

I have made an application using C# in windows forms. I am using Install shield 2010 to create a setup file for the application. It asks me what it should check for as prerequisites which it would check for before starting to install on any other device.
However, I do not know what I should include as prerequisites for my windows application. I do not know if it requires .net 4.5 or 4 or 3.5... I also had downloaded and included some references in the project and do not know if they are being included in the setup or not...
Please help
You need to look at the project properties of your winform app and see what version of the .NET framework you are building against. In some cases you can do things like compile against .NET 2.0 but then have an App.Config file that says 2.0 and 4.0 are supported runtimes. This gives you flexibility in choosing which if any .NET to redistribute.
From there you have to look at your dependencies (references) and there dependencies. It's possible that they require additional things such as C++ runtimes, database engines. For each of these you have to figure out if it's already part of windows, if a third party redistributable exists, can it be statically linked or privately deployed and so on.
There is no one simple answer. You just have to be familiar with your code base, what it requires and what the best practices are for each of those items.

Categories