I am a beginner in software development. I was following a simple tutorial and was creating a web application in Asp.net MVC - 5. But suddenly my app stopped running even I did not do any fancy stuff. Below is the error I am getting. Please help me here.
Error: System.typeloadexception.
Additional: Microsoft,Ajax.Utilities.OutputVisitor from assembly 'WebGrease'
I have not touched these fancy stuff at all. But as soon as I run the application in local host I start getting this error. Error comes in _Layout.cshtml file near the line
#Scripts.Render("~/bundles/modernizr")
This can happen if your targeted .Net framework version not installed on your System. Check your project properties .Net version and check your Pc has respective .Net installed.
try
{
}
catch (TypeLoadException)
{
// this can happen if respective .Net is not installed in your system
}
TypeLoadException is thrown when the common language runtime cannot
find the assembly, the type within the assembly, or cannot load the
type.
or add this code snippet
AppDomain.CurrentDomain.AsemblyResolve += (s, e) =>
{
return AppDomain.CurrentDomain.GetAssemblies()
.SingleOrDefault(asm => asm.FullName == e.Name);
}
If all attempts fails, try to reinstall WebGrease nugget package
Related
I am attempting to use AddictedCS SoundFingerprinting (https://github.com/AddictedCS/soundfingerprinting).
When I download any recent version and build with Visual Studio 2019 I get the expected output with no errors or warnings (SoundFingerprinting.dll).
The issue is that when I attempt to call functionality from the DLL in a .net console application I get errors relating to netstandard referencing.
I've attempted to add a new reference manually as the error message suggests, but get no further - same error occurs.
Here is my code, taken straight from the SoundFingerprinting example:
var hashedFingerprints = await FingerprintCommandBuilder.Instance
.BuildFingerprintCommand()
.From("C:/Users/Asher/Desktop/testSound.wav")
.UsingServices(audioService)
.Hash();
Here is the error log I am getting when compiling my console app with either mcs or csc:
C:\Users\Asher\Desktop\Raw_0.1>mcs TestProg.cs
-r:SoundFingerprinting.dll -r:protobuf-net.dll TestProg.cs(46,40): error CS0012: The type System.Object' is defined in an assembly that
is not referenced. Consider adding a reference to assembly
netstandard, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'
C:\Users\Asher\Desktop\Raw_0.1\SoundFingerprinting.dll (Location of
the symbol related to previous error) Compilation failed: 1 error(s),
0 warnings
I attempted this on my desktop PC running Windows 10, and on my Surface Pro 6 running Windows 10. I also attempted this using VS2017. The result was the same each time.
Also tried to use the library in Unity3D which caused a crash with no prompt or stacktrace output.
To Reproduce
Use: Windows 10, Visual Studio 2019
Steps to reproduce the behavior:
Download latest release (v7.2.0-beta3)
Build libraries
Attempt to call functionality from SoundFingerprinting.dll via a console application
I encountered exactly the same problem today. What fixed it for me was simply downloading the latest version of protobuf-net from nuget:
Install-Package protobuf-net -Version 3.0.101
Also, please don't paste pictures of code but the code itself next time.
I am attempting to implement a QR Code reader from within HoloLens, working off of Mike Taulty's solution (https://mtaulty.com/2016/12/28/windows-10-uwp-qr-code-scanning-with-zxing-and-hololens/). However, I am having an issue with building out the project in Unity, as I am getting a build error: "Assets\Placeholder.cs(20,9): error CS0103: The name 'MediaFrameQrProcessing' does not exist in the current context", which seems to be implying that the DLLs aren't working properly? A already have a DLL by the same name in my project, and I would assume that this DLL would cover this issue, but it appear to not.
I am running Unity 2018.4.1 and Visual Studio 2019. I am building on top of his GitHub repo (https://github.com/mtaulty/QrCodes).
This is the block that throws the build error. MediaFrameQrProcessing cannot be found
public void OnScan()
{
this.textMesh.text = "scanning for 30s";
#if !UNITY_EDITOR
MediaFrameQrProcessing.Wrappers.ZXingQrCodeScanner.ScanFirstCameraForQrCode(
result =>
{
UnityEngine.WSA.Application.InvokeOnAppThread(() =>
{
this.textMesh.text = result ?? "not found";
},
false);
},
TimeSpan.FromSeconds(30));
#endif
}
Expected: Project Builds w/o incident
Actual Results: Assets\Placeholder.cs(20,9): error CS0103: The name 'MediaFrameQrProcessing' does not exist in the current context build error. This should be covered by the DLL
Screenshots of the import settings:
It is recommended to try to build with unity2017. I built the unity project in repository with unity2017.4.31f1 and it seemed to work fine.
Update:
I used 2018.4.3 to create a new project and did some simple tests, this error was not thrown after using such a Import Setting.
I have a simple application that starts as a service using topshelf and it looks simple:
HostFactory.Run(x =>
{
x.Service<RequestService>();
x.RunAsLocalSystem();
});
Well it works, but under windows. When I tried this under Linux I am getting:
Topshelf.Runtime.Windows.WindowsHostEnvironment Error: 0 : Unable to get parent process (ignored), System.DllNotFoundException: Unable to load shared library 'kernel32.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libkernel32.dll: cannot open shared object file: No such file or directory
Has someone came across this problem?
I tried to google it but someone said it works other that it is tool only for windows.
Or maybe there is some other service hoisting framework for .net core?
Topshelf is not advertised as cross-platform and so it does not (or did not at the time of writing) official support .Net Core on non-Windows environments, even if it can run in them (at least at the time of writing, see below).
The solution is to change the environment builder when running on non-Windows hosts.
Here is an example from my project. When creating the service, pick the env builder at runtime based on the host OS.
HostFactory.Run(c =>
{
// Change Topshelf's environment builder on non-Windows hosts:
if (
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ||
RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
)
{
c.UseEnvironmentBuilder(
target => new DotNetCoreEnvironmentBuilder(target)
);
}
c.SetServiceName("SelloutReportingService");
c.SetDisplayName("Sellout Reporting Service");
c.SetDescription(
"A reporting service that does something...");
c.StartAutomatically();
c.RunAsNetworkService();
c.EnableServiceRecovery(
a => a.RestartService(TimeSpan.FromSeconds(60))
);
c.StartAutomatically();
c.Service<SelloutReportingService>();
});
Assuming that you installed this version of Topshelf - you would notice under dependencies that it doesn't support .NET Core and therefore it will not run under a Linux environment.
It will only run under a Windows environment as you mentioned in your post. kernel32.dll is a Windows dependency that it cannot find, therefore it cannot run.
I start encounter a new runtime System.IO.FileNotFoundException exception after upgrade my system from win7 x64 to win 10 x64.
I have the following code that works perfect until now:
{
PrincipalContext pc = new PrincipalContext(ContextType.Machine, Environment.MachineName);
UserPrincipal usrPrin = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, Username);
if (usrPrin == null) // No user exist
{
return -1;
}
// user exist
return 1;
}
I always built the project using the platform target: x86, when I run the application, I get the exception when call UserPrincipal.FindByIdentity.
A first chance exception of type 'System.IO.FileNotFoundException'
occurred in System.DirectoryServices.dll A first chance exception of
type 'System.IO.FileNotFoundException' occurred in
System.DirectoryServices.AccountManagement.dll
All my projects compile with .net4 and not .net4.5
during my debug now, I find that if I change the build platform target to AnyCPU, the code passed with no issue.
It seems like an OS bug! .Net 4 x86 not installed or something not right!, I tried to reinstall .Net4 but couldn't because it already installed, Iran .net cleanup tool as well.
Any Idea why this exception?
It says the assembly System.DirectoryServices.dll missing. Did you get a chance to verify if the dll is present in your current solution. If not try to download for nuget, build and see. I faced a similar issue and it got resolved with vs 2017 and .net core 2.1 after downloading the System.DirectoryServices dll
I am having to building mono from sources, since the Ubuntu package from badgerports is outdated (does not support .Net 4.0)
This is what I have done so far (mostly following instructions here):
cloned mono git repository
switched to branch tagged 2.6 (git checkout mono-2-6)
installed minimal mono on my machine so mono and mcs are available on machine
run ./autogen.sh --prefix=/usr/local
run make
After a few modules compile correctly, I get this error:
make[4]: Entering directory `/home/oompah/work/dev/mono/mono/mini'
CC mini.lo
CC liveness.lo
liveness.c: In function ‘mono_liveness_handle_exception_clauses’:
liveness.c:137: error: ‘MonoCompile’ has no member named ‘header’
make[4]: *** [liveness.lo] Error 1
make[4]: Leaving directory `/home/oompah/work/dev/mono/mono/mini'
make[3]: *** [all] Error 2
I have looked at the offending code, and indeed a header member is being accessed ...
void
mono_liveness_handle_exception_clauses (MonoCompile *cfg)
{
MonoBasicBlock *bb;
GSList *visited = NULL;
MonoMethodHeader *header = cfg->header;
...
}
Has anyone managed to build mono-2.6 (or later) on Ubuntu?
I've used the scripts provided at integratedwebsystems successfully to compile a recent version of mono on my system and run .net 4.0 applications.
an improved version of the script can be found on firegrass' github account
Joe Shields is packaging Mono 2.10 and is patching everything to default to .NET 4.0 for Ubuntu, you might want to poke him on twitter #directhex.