# Issue/conflict with system.runtime.compilerservices.unsafe

That's what is more important than anything else

 Forums    Topics    Search    Help    Login    Register
Issue/conflict with system.runtime.compilerservices.unsafe

Ben Gijsen

Posts: 19
Joined: 2008-04-18
 I've a problem which may be a little off-topic as it concerns co-operation between ADX and other software, but I think more developers run into similar problems. So I created a very simple Word AddIn to test combination with the use of Azure Files. To addinmodule.vb I've just added:  Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick Dim ascShare As ShareClient, strShare As String Try strShare = "opsdata01" ascShare = New ShareClient("DefaultEndpointsProtocol=https;AccountName=... account ....;AccountKey=... key ....;EndpointSuffix=core.windows.net",strShare) If ascShare.Exists.Value Then MsgBox("Yes, share " + strShare + " is there") Else MsgBox("No, share " + strShare + " was not found") End If Catch excErr As Exception MsgBox("Error: " + excErr.Message) End Try End Sub  When I click the button an exception is raised (Source: System.Memory) with text Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) This only happens when I use Add-In Express (standard, latest version). If I create a basic Windows Forms application with the same body in a button's handler it works without any issue. Any idea how to solve this? I already tried redirecting the assembly's reference to 4.0.6.0, but that gives the same issue (only another number). Installing NuGet System.Runtime.CompilerServices.Unsafe 3.5 solves it in my development enviroment but I get downgrade warnings and when I create a .msi, the deployed version again has the same issue. Using: .Net Framework 4.7.2, VS 16.11, Add-In-Express adxnet-v905-b4661-vs-std, NuGet package Azure.Storage.Files.Shares 12.8
 Posted 22 Oct, 2021 10:11:18 Top
Andrei Smolin

Posts: 17953
Joined: 2006-05-11
 Hello Ben, What .NET Framework version is ShareClient built for? Regards from Poland (CEST), Andrei Smolin Add-in Express Team Leader
 Posted 25 Oct, 2021 02:53:03 Top
Ben Gijsen

Posts: 19
Joined: 2008-04-18
 Hi Andrei, Thanks for your quick response. Currently I'm using .Net Framework 4.7.2 (I summed up all versions of VS, ADX, etc at the bottom of my post). I've installed other versions (Core and Net5), but can't select these for my ADX project. In the mean time I already tried various suggested solutions: Binding Redirect assembly versions , doesn't seem to do anything (at least not in my case; tried with option "Auto-generate " on and off for the project). Using different versions by specifying CodeBase solved the problem when I run (debug) the application from VS, but when I created a .msi file (to which I added the app.config file and the alternative .dll as assembly) this installed correctly, but threw the error again. (BTW: I used the "Create Setup project" from the Add-in Express menu. Regards, Ben
 Posted 25 Oct, 2021 04:05:08 Top
Andrei Smolin

Posts: 17953
Joined: 2006-05-11
 Hello Ben, Select ShareClient in References: what value do you have in the Runtime Version property? Regards from Poland (CEST), Andrei Smolin Add-in Express Team Leader
 Posted 25 Oct, 2021 07:32:59 Top
Ben Gijsen

Posts: 19
Joined: 2008-04-18
 Hi Andrei, The ShareClient is a class from the Azure.Storage.Files.Shares package which is installed in VS via NuGet, so I don't see any of the actual dlls. In the reference list it has a different icon from the rest (eg. ADX), and if I open the properties window, nothing shows up. Regards Ben
 Posted 25 Oct, 2021 08:03:07 Top
Andrei Smolin

Posts: 17953
Joined: 2006-05-11
 Hello Ben, You have a reference to a DLL responsible for this functionality. I suppose, the reference name is Azure.Storage.Files.Shares. Say, the reference named AddinExpress.MSO.2005 provides your add-in with the functionality of Add-in Express. Click it and press F4 to open the Properties window where you'll see that the Runtime Version is v.2.0.50727. Regards from Poland (CEST), Andrei Smolin Add-in Express Team Leader
 Posted 25 Oct, 2021 09:03:17 Top
Ben Gijsen

Posts: 19
Joined: 2008-04-18
 Hi Andrei, Yes I have that reference but it works different. There's a different icon next to it in the list in the Solution Explorer and I get an empty list of Properties. For ADX I can get a list, which e.g. tells me its Version (9.5.4661.0), Runtime Version (v2.0.50727) and more. On the Project Page, the reference to Azure.Storage.Files.Shares also is not in the upper pane labelled References (that's where I see ADX, the Office dlls and varius System dlls), but it's only visible in the lower pane labelled Imported namespaces where I have selected it, otherwise I (obviously) get the error "Type 'ShareClient' is not defined". BTW: is there a way I can include a picture from disk (screenprint) in my response; the IMG button only allows a http:// url for adding. Regards Ben
 Posted 25 Oct, 2021 09:21:03 Top
Andrei Smolin

Posts: 17953
Joined: 2006-05-11
 Hello Ben, Could you send a sample project to the support email address? I'll install Azure SDK for .NET and test the project. Regards from Poland (CEST), Andrei Smolin Add-in Express Team Leader
 Posted 25 Oct, 2021 10:49:04 Top
Andrei Smolin

Posts: 17953
Joined: 2006-05-11
 Hello Ben, Thank you for the project. I reproduce the issue. Upon inspection, the System.Runtime.CompilerServices.Unsafe.dll file supplied is a .NET Core file while the project is based on .NET Framework. Maybe, they have a .NET Framework version of that file? Just recently we posted an explanation why Add-in Express won't support .NET 5-6, etc.; see https://www.add-in-express.com/forum/read.php?FID=5&TID=16208. Regards from Poland (CEST), Andrei Smolin Add-in Express Team Leader
 Posted 26 Oct, 2021 08:44:24 Top
Ben Gijsen

Posts: 19
Joined: 2008-04-18