I am working in .NET framework 4.8 (correction: my Visual Studio installation was 4.8, the application was targeting 4.5 - this was the source of the problem, which is now solved) and trying to use the QueueBackgroundWorkItem method of the HostingEnvironment class, but when I write it into my code, I get this message:
BC30456: 'QueueBackgroundWorkItem' is not a member of 'HostingEnvironment'.
I have used Imports System.Web.Hosting at the top of my script. System.Web.Hosting imports OK and the HostingEnvironment class shows up highlighted in my code, as it should. The class HostingEnvironment is recognised and has methods, but QueueBackgroundWorkItem isn't one of them.
I get a similar error when I try to use this method in C#.
CS0426: The type name 'QueueBackgroundWorkItem' does not exist in the type 'HostingEnvironment'.
I've searched for the System.Web.Hosting library in NuGet to see if there were any updates, but nothing came up. Google searches for these errors haven't got me anywhere, other than to links explaining how to use the HostingEnvironment method.
Related
I want to test the performance of some methods using BenchmarkDotnet. Therefore, I downloaded the NuGet package added the usings and implemented it like this:
BenchmarkRunner.Run<SortingAlgorithmBenchmark>();
public class SortingAlgorithmBenchmark
{
[Benchmark]
public void BubbleSort()
{
SortingAlgorithms.BubbleSort(new[] {2,3,1});
}
}
The BenchmarkRunner is in a console application which should show the output. Unfortunately the I keep getting this error: MSB3971: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher
I don´t know where this error comes from since I never had a problem with the assembly references before and everything should be installed properly. At least I don´t know what could be wrong. Does anyone have an idea how to solve this problem. I run the program in VS 2022 and the TargetFramework is .Net 6.0
dotnet sdk folder
Microsoft.NET folder
It turned out that the problem was an unnecessary environment variable which pointed to the wrong sdk. After deleting the variable and restarting Visual Studio everything worked out fine.
Trying to establish an xmlrpc to a third party web service from my function app. It works fine from localhost, and indeed, it works in other functions but when published to Azure I'm getting this error:
System.MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.
at CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, String assemblyName, String moduleName, String typeName, AssemblyBuilderAccess access)
at CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf)
at CookComputing.XmlRpc.XmlRpcProxyGen.Create[T]()
It's failing at this line:
_serviceClient = XmlRpcProxyGen.Create<IServiceClient>();
IServiceClient is an interface that looks like this:
using CookComputing.XmlRpc;
using System;
namespace App.Core.Helpers.Service
{
[XmlRpcUrl("https://some.url")]
public interface IServiceClient : IXmlRpcProxy
// methods
}
I've manually added the System.Reflection.Emit package to the solution in an attempt to fix it, but no joy. The exact same code is running fine in other apps we have in Azure. The app is running .Net framework 4.6.1.
This is a problem which can occur when there is an old version of a DLL still lingering somewhere around. Make sure that the latest assemblies are deployed and no duplicated older assemblies are hiding in certain folders. Your best bet would be to delete every built item(Clean Build) and Rebuild/redeploy the entire solution.
In particular, be sure an old version is not in the GAC.
This can help to Remove an Assembly from the Global Assembly Cache.
I was facing same issue as you were facing.
What I found solution is that, I was using asp.net core framework So I have to change it into net 4.5 framework. And that's all.
Issue resolved.
So you may try that.
I am creating an Azure Function in C# using a target framework of netstandard2.0 in a Windows 10 environment. The function calls a method that's in another class library and that method creates an instance of SqlConnection. When I run the function I get the following exception:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
while executing function: Functions.RefreshImages --->
System.Reflection.TargetInvocationException : Exception has been
thrown by the target of an invocation. --->
System.PlatformNotSupportedException : System.Data.SqlClient is not
supported on this platform. at
System.Data.SqlClient.SqlConnection..ctor(String connectionString)......
Obviously SqlConnection is supported on Windows so I assume there's something else going on here.
This happens when a .Net Standard lib that uses a SqlConnection is loaded dynamically via reflection. The .Net Standard lib will typically reference System.Data.SqlClient which seems to be a dummy lib without actual implementation. It apparently ensures that the lib will compile on all platforms, including those without Registry and other platform specific stuff that the real SqlClient implementation relies on.
The easiest solution I can find is to add a reference to the Microsoft.Data.SqlClient NuGet package in the host application (the .Net core application that dynamically loads the .Net standard lib).
You may see a small yellow warning exclamation icon in the Solution explorer because Visual Studio thinks you are not using the lib and if you use the "Remove Unused References" feature it will also suggest removing the package. There is a feature to suppress warnings in the PropertyGrid, but I cannot figure out wat number should be filled in since the warning does not appear in the error list when compiling...
It looks like this is related to loading a SQL connection via reflection in .NET core (you are running on netstandard2.0 but the principle should still be the same).
I'm attempting to use the following command line command to compile an assembly of the code from my project:
C:/"Program Files"/Unity/Editor/Data/Mono/bin/gmcs
-target:library -out:C:/Users/Austin/Desktop/PixelExpanse.dll
-recurse:C:/Users/Austin/Desktop/Projects/Repos/trunk/PixelExpanse/SpaceColonyRefactor/Assets/Source/*.cs
-d:RUNTIME -r:C:/"Program Files"/Unity/Editor/Data/Managed/UnityEngine.dll
As you can see, I am, I believe, correctly referencing the UnityEngine.dll.
The code that would be compiled contains references to UnityEngine.UI and UnityEngine.EventSystems. But when I run the above command, I get the following compile error:
error CS0234: The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?
From what I have been able to find through googling, it SEEMS like an error people were getting when using a pre-4.6 assembly, because thats when EventSystems and UI were both introduced. But I don't know how I could be missing that in the dll I'm referencing as Unity 5 is the only version that has ever touched this computer.
As a side note, I have posted this question to Unity Answers and have yet to receive a response. I expect it's because assembly compilation is beyond the scope of what most users there choose to undertake. Hence my asking it here.
The namespace UnityEngine.EventSystems actually appears in UnityEngine.UI.dll and not UnityEngine.dll so it seems you need to reference the former too when compiling manually from the command-line. Unity projects have this by default (see below).
This is verified by opening up the assembly in your reflector tool of choice, here I am using JetBrains dotPeek:
This is how my test project appears with default Unity references. Note that by default a reference to UnityEngine.UI already appears in the Unity-created project:
When I built my Windnows desktop app via Unity, the above dlls appeared in:
<drive>:<projectOutFolder>\<projectName>_Data\Managed
You can try:
right click on "project panel", and after "Reimport All".
It's can be happen due to switch between platforms, e.g. IOS, or Desktop.. thus, folrders are deleted by became unecessary..
Solve for me: Unity 5.2, Win 7, 32bits;
Good luck!
I checked the UnityEngine.dll and the Eventsystems/UI namespace is not included. Despite, there is a dll in Unity5\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll which includes these namespaces.
For mac, it's /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll.
I needed to make a console application using nettiers class libraries. I created a new Console Application project, added references to all the libraries from NetTiers and created an app.config file with all the necessary configurations. I get intellisense and no errors and everything when I am doing the coding, but when I go to compile the application, I'm getting an error that PPGEDI.Data doesn't exist.
I only have 1 line in the program.cs Main method:
PPGEDI.Entities.VansEntity van
= DataRepository.VansEntityProvider.GetById(16);
I'm getting the following error:
Error 93
The type or namespace name 'Data'
does not exist in the namespace 'PPGEDI'
(are you missing an assembly reference?)
It's frustrating, because I know I've added the assembly reference:
I'm using Visual Studio 2010, with C# and .NET 4.0. Can anyone give me an idea as to what I need to do to get this to work.
As a note, this works if I use the same statement in a method on an ASPX page in the web application generated by nettiers.
#BrokenGlass, you were absolutely correct. I double checked and it was
set to ".NET Framework Client Profile", I changed it to .NET 4 and
it's working now, can you put that as an answer?
You are using the .NET client profile in your console app which is a "minified" version that doesn’t contain all assemblies.
The problem is that when your app adds a reference to a class library that is targeting the full framework, references to the "full" framework assembly will not resolve. This results in the rather non-forthcoming error message that you see. Switching to the the full .NET 4 as target framework will resolve the issue.
For a more in depth overview of the problem and the .NET 4 Client Profile in general also see "What’s new in .NET Framework 4 Client Profile RTM"