EPPlus library and SharePoint 2010 - sharepoint-2010

I'm using the EPPlus library in a Visual Studio 2012 SharePoint 2010 project and get the following 'file not found' exception from an Application Page when I add "ExcelPackage pck = new ExcelPackage();" as the starting point of creating an excel file:
Could not load file or assembly 'EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1' or one of its dependencies. The system cannot find the file specified.
The library registers without a problem and the project builds and runs until the function containing the EPPLus code is called.
The same code works fine on the same machine in a standard asp.net web application.
Any suggestions appreciated, thanks.

You need to deploy the Assembly in the GAC.
You can add it using something like GacUtil or include the assembly in your solution by adding it to the solution package.
In solution explorer, double click on Package.
In the Package properties select the Advanced tab
Add the assembly in Additional Assemblies

If you are trying to access this library inside inline code in an ASPX page (e.g. between <% and %> tags), then you'll need to add a reference to the assembly in the web.config so when the page is compiled on demand, the compiler will reference it.
<compilation debug="true">
<assemblies>
<add assembly="EPPlus, Version=3.1.3.0, Culture=neutral, ..." />

Related

Building VSIX project in Release does not create a VSIX file anymore, just a DLL

I think the title is pretty clear. I always build in Release mode and upload the created VSIX file to the VS Marketplace.
Since today, it just creates a .dll file when I build in Release mode, no VSIX is generated. Also,in Debug I cannot set break points anymore, symbols won't load.
After reverting the commit (5 lines of code) to the previous version the problem still occurs.
I have no idea what could have caused this. Anyone experienced this before and what can I try to resolve this?
Edit:
This shows up in the build log, can this be the cause?
warning CS1762: A reference was created to embedded interop assembly 'EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because of an indirect reference to that assembly created by assembly 'Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Consider changing the 'Embed Interop Types' property on either assembly
When I set the Embed Interop Types property to true on the EnvDTE assembly I get service can not be embedded errors throughout the package code.
I tried creating new VSIX projects or opening older ones, no issues there, it creates a .VSIX file when building in release mode. Comparing the CSPROJ files and configuration shows no difference.

ASP.NET Core 2.1 CI/CD build error using VSTS

I created a brand new ASP.NET Core 2.1 project in VS2017 and then I created a pipeline with VSTS using 'ASP.NET Core' in VSTS. When the build runs I get this error all the time:
The "WebCompiler.CompilerBuildTask" task could not be loaded from the assembly C:\Users\VssAdministrator.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\a\1\s\SukiCore\SukiCore.csproj]
So what should I do to fix this?
ok, for some reason I had this in .csproj file, so it started working when I commented it out:
<!--<PackageReference Include="BuildWebCompiler" Version="1.11.326" />-->
I think it got there when I added a new view using 'Add View' menu in the solution explorer.

Xamarin namespace issues in XAML files when changing startup project in VS

I have issues with Xamarin in Visual studio 2017 15.8.0 Preview 4 (And all previous builds)
I have a Xamarin forms project with a Android Project and a UWP project, if I change the startup project to UWP and try to compile I get this error
Error Failed to resolve assembly: 'FoosballXamarin.Android,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' FoosballXamarin.UWP ...\Views\LoginPage.xaml
And the XAML itself will give me errors on these lines
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.Android"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.Android"
And want me to change them to
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.UWP"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.UWP"
Is there a way to write it differently so I dont get this error every time?
Based on the errors you're seeing, I'm going to guess you have this configured as a shared project (not PCL/.netstandard). If that's the case, simplify the lines in the XAML file to:
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers"
In other words, just remove the assembly= part. If you don't specify the assembly on the xmlns line, it will assume the namespace is the same assembly as the XAML file. So you only need to include it if it's in a different assembly.
Since shared projects include the XAML file in multiple assemblies (one per platform), you pretty much have to omit the assembly= on the xmlns declaration for namespaces/types in the same assembly.

Could not load file or assembly 'LibGit2Sharp.GitServer, Version=14.0.0.0, Culture=neutral, PublicKeyToken=xx' or one of its dependencies

I was trying to execute a powershell script after tfs build by customizing the default process template using vs2017. According to this article i have to use InvokeProcess and ConvertWorkspaceItem activities. Since it was not found in the tool box, referring from here, I tried to add Microsoft.TeamFoundation.Build.Workflow.dll to the tool box. But the following error shows up
Could not load file or assembly 'LibGit2Sharp.GitServer, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies
I am really stuck in this. Any help

Weird problem with Visual Studio 2008 website reference

I'm trying to add a reference to the GAC version of System.Xml in a Visual Studio 2008 web site project. I right-click the project icon in the Solution Explorer, and click Property Pages. Under the References tree option, I click the 'Add' button on the right. I navigate to System.Xml in the .NET tab, and double click it (the Path it lists for System.Xml, C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll, DOES exist). The dialog disappears, but... System.Xml does not get added as a reference! The list just stays the same.
I tried adding another .NET reference just to make sure others could be added OK, I added System.Web.RegularExpressions and it added fine. What on earth could be causing it not to add System.Xml?
Try to edit your vbproj file, and add
<Reference Include="System.Xml" />
I just created a ASP.NET Website with default language C# & .NET 2.0 as the target. I also observed that even if you try to add a reference to System.XML, you will not find one in the project proprieties page.
As far it goes for me, its as designed.
By default you can access all the default .NET namespaces (in your target version) by just adding "using NAMESPACE_NAME;" in you code behind.(System (& the sub namespaces like XML etc). ASP, Microsoft & MS) Only when you reference a third party .NET dll or something that's not default for an ASP.NET Website project (could not find the list of defaults on the net), then a new folder called bin is created & a copy of that dll is stored in it if it is not in GAC.
EDIT: Regarding not able to add a cs file to vb file, I just did that, & I could access System.Xml namespace in the vb file.
Well it looks like it might have had something to do with my trying to add a .cs file to a project where the rest of the files were in vb.net. Hmph, I thought one of the major benefits of .NET was you could easily mix languages. Oh well, I removed that and added these lines into my web.config file:
<add namespace="System.Xml"/>
and
<add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
and now it compiles OK. I can access System.Xml from within VB code, so it looks like I'll have to translate the class I had from C# to VB.net. Hmph.