Precompiled Azure Function Dependency Error - c#

I'm building a simple web hook function that does some work against Azure Resources using the C# Resource Manager API. The build fails with:
.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
I've checked and everything is pulling Newtonsoft.Json 9.0.1. I'm guessing it's due to some mismatch in my Nuget packages but not sure how to dig in?
I have:
Microsoft.Azure.Management.ResourceManager 1.6.0-preview
Microsoft.NET.Sdk.Functions 1.0.2
Microsoft.Rest.ClientRuntime.Azure.Authentication 2.3.1
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json.Linq;
using Microsoft.Rest.Azure.Authentication;
Using VS2017 15.3.3

It all came down to the preview Resource Manager package.
Microsoft.Azure.Management.ResourceManager 1.6.0-preview
Since this is Open Source I went to the GitHub project and checked it out. Essentially came down to it requiring a specific version of NewtonSoft. I fixed my problem by placing the code using the resource manager API into one assembly and just used that. This now works fine in Azure Functions.
In short, look at the dependencies, isolate them in an assembly then include that in your project.

Related

How to update System.Data version to 2.0.5.0

First of all, I'm working with Visual Studio 2015 (and can't upgrade VS version) and using a MySQL library. My using directives are
using System;
using System.Data;
using MySql.Data.MySqlClient;
And I'm trying to connect with a MySQL database with
MySqlConnection ms = new MySqlConnection(ConnectionData.ToString());
ms.Open();
The name of the function Open() is autocompleted ok, and I know it works fine on another projects I have been working on, but now I get this compiler error when trying to invoke the Open() function:
Must add an assembly reference 'System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I think my System.Data library is quite old, but I can't find a System.Data.dll file in my project (That way I could just replace it), anyone know how to just upgrade that library?

C# Change using namespace reference dll path dynamically IN .NET LIBRARY PROJECT

I have a class library .net project(no config,no exe file) and I have something like this;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Web.UI.WebControls;
using eBAControls; *<-- I want this dll to be loaded from a path in runtime.*
I have to make copyLocal false for future reasons thus i need to be able to refer the dll in runtime. Other 3rd party dlls which are in same folder with this current dll do not cause any problems but eBAControls dll is not in the same folder with this current dll thus it gives the error: Could not load file or assembly 'eBAControls...
I can not also use reflection for that for some coding and performance reasons thus it needs to be added to references...
Shortly what i want is
using eBAControls = #"somepath"; <- that is set dynamically for ex while one of my methods are being executed etc...
You can load the assembly from wherever you like if you place an event handler on AppDomain.AssemblyResolve. See Resolving Assembly Loads
Here's a blog post that has the essentials. The key is timing. You have to attach the event before the first method referencing the assembly is JITted. https://blogs.msdn.microsoft.com/dbrowne/2014/06/25/how-to-load-an-assembly-in-a-ssis-script-task-that-isnt-in-the-gac/

How do I designate the location of a library in order for a "using" statement to work (C#)

I'm used C# -some- but not recently.
I've got this header from some code, and it calls a custom non-system library, (Dynastream.Fit, at the bottom), but I need to know how to tell the program where it resides so it can compile. Pretty sure the library is in the SDK I downloaded, just need to find it. This is the FitSDK from ANT+.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using Dynastream.Fit;
You need to add the dll of Dynastream.Fit to your project Reference folder by right clicking the reference folder -> add reference -> Browse -> choose the dll; unless you have already installed the assembly in GAC.

Why is the reference for ConfigurationErrorsException missing from my .Net 3.0 application?

I have a .NET 3.0 Winform Application with a corrupt user.config file causing system config errors.
I wanted to improve handle these errors, similar to how it's done in this example on CodeProject.
To use '
However, when I try and use the 'ConfigurationErrorsException' to get the name of corrupted file I receive the following error:
The type or namespace name 'ConfigurationErrorsException' could not be found (are you missing a using directive or an assembly reference?)
I have only seen this error previously where there were .NET framework conflicts.
The project has the target framework .NET 3.0. The ConfigurationErrorsException was added in 2.0, so I didn't think there would be a framework conflict there.
The version 3.0 documentation is lacking compared to other versions and does say:
The current value is not one of the EnableSessionState values.
Which I'm not entirely sure what that implies (the documentation for EnableSessionState lead to more confusion rather than less).
Why does the program fail to build, with a type or namespace missing error?
Is this related to targeting .NET 3.0?
If so, Is there an alternative for .NET 3.0?
EDIT:
I have made sure to include 'using System.Configuration' at the top of my page. The total list of usings is:
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Threading.Tasks;
using System.Configuration;
using System.Windows.Forms;
using System.Threading;
using ProjectName.Properties;
using System.Security.Permissions;
using Microsoft.Win32;

C# using System.Xaml missing assembly reference

I'm writing a C# Console Application that is targeted towards .Net 4.5. I want to use Xaml Services to save and read a List data structure to file. I'm using VS 2013 Pro.
The .net doc's say Xaml has been in .NET since 4.0(?) I have my projected targeted to 4.5, but even with 4.0, 4.5.1, 4.6, and 4.6.1... same missing assembly reference. I'm doing a
using System;
using System.Collections.Generic;
using System.IO;
using System.Xaml; // <-- this is getting the assembly error
using System.Xml;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
But that is where the missing reference is getting the error...
I've used it before in Win Forms. It is that maybe it's excluded for console applications? Or am I missing something that Xaml Class depends on before using that assembly?
Could it be that you did not add a project reference to the assembly "System.Xaml.dll"? The Xaml functionality is not contained in the assemblies which are included in a new VS console project by default. (Right-Click on the "References" entry of the project, then select "Add References", then browse to "Framework" and look for System.Xaml, which refers to the dll of that name).
A namespace however does not necessarily correspond uniquely to an assembly, so you might require even more assemblies. If you know which types you need, you can browse the MSDN documentation for looking which assembly might still be required.

Categories

Resources