Mathnet.Numerics suddenly requires CUDA DLL - math.net

I maintain a .Net Framework 4.0 application (yes, I know) that depends on Mathnet.Numerics 3.11. Recently I started getting DllNotFoundException, saying that I lack MathNet.Numerics.CUDA.dll, when I call either Matrix<T>.Solve(Vector) or DenseMatrix.QR(). I reverted to older versions and found the problem persists. This is crippling for the application, and I'm really hoping to find out what I can do to make it work again. (Separately, I do have a project underway to rewrite the application in .Net 6, but that will not be done soon.)
I did find this GitHub issue which is not encouraging.
Is there a .Net Framework 4.0 version of MathNet.Numerics.CUDA.dll available somewhere? That would probably be the simplest solution, although I suspect it may be hardware dependent.

Just upgrade MathNet.Numerics to 3.20.2 (the latest release within major version 3) and the problem goes away. It appears that the implementation was changed to package the native BLAS providers within the main DLL rather than requiring a separate DLL for each one.

Related

Running Azure functions will result in .net 4.7.1 installation prompt dialog

When I try to run (debug) functions in Visual Studio 2017 on one of our machines, the following dialog pops up!
The target framework for the project is <TargetFramework>net461</TargetFramework>. For some reasons I am not able to install .NET 4.7.1 and now I am completely lost. I am sure it was functioning in the past on the same machine. Probably one of the updates caused it.
Any idea how to resolve it?
This is because the latest version of the Azure Functions Tools for Visual Studio now requires .NET Framework 4.7.1 (as of February 2018).
Note that this does not impact the target framework that you compile against - only the target framework your code runs against. Similarly, when you run in Azure, you can expect the .NET runtime version to be .NET Framework 4.7.1 (at the time of writing).
I tried implementing the solution mentioned in comment. However, it didn't work for me. However, reverting the Azure Functions Tools to previous version worked. Thanks Chris for pointing that it was Azure Tools and not any packages that caused it.
If anyone else should come across this.
For me, the issue was the actual func.exe config that needed to be upgraded.
Navigate to:
C:\Users[USER]\AppData\Local\AzureFunctionsTools\Releases[VERSION]\cli
.. my version was 1.4.0
Modify the func.exe.config to match the .net version installed
.. it was 4.7.1

HttpRequestMessageExtensions not being found at run-time in Azure Function

I've got an Azure Function app that creates a precompiled DLL (so it uses normal .cs files, not the older .csx method, pre-VS2017). Previously, it was targeting .Net Framework 4.5.2. I updated it to 4.7 so as to use some of the new C# 7 features. I updated my NuGet packages by doing "Update-Package -Reinstall" and verified that they all have the "net47" target set in my packages.config file.
Everything compiles fine. But when I call a function that uses either of 2 HttpRequestMessageExtensions methods, I get an exception. One example of the exception is this:
Method not found: 'System.Net.Http.HttpResponseMessage
System.Net.Http.HttpRequestMessageExtensions.CreateResponse(
System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode)'.
Here's an example of a tiny test function that will cause the error:
using System.Net;
using System.Net.Http;
public static HttpResponseMessage Run(HttpRequestMessage req)
{
return req.CreateResponse(HttpStatusCode.Accepted, "");
}
Upon calling this function with say Postman, I'll receive the aforementioned exception. I also get a similar method not found exception when I call GetQueryNameValuePairs() on the HttpRequestMessage.
I've tried updating my NuGet packages to the latest, no difference. I've cleaned and rebuilt and restarted a bunch of times, making sure to nuke my bin and obj directories.
I'm not sure what could be the problem. I guess I could downgrade back to .Net 4.5.2 but I'd rather not. For one, I want to use C# 7, and for two, I want to understand what the problem is rather than avoid it.
Update: interesting. The issue seems to be with System.Net.Http. If I lower it to 4.0.0 everything works fine. If I raise it to any higher version I get the issues listed above. I tried selectively lowering each of my packages, one by one, to their previous version number to find this out. I then updated all but this one to the latest version and it fixed the issue.
I also tested it on my side. The issue is related to the latest version of System.Net.Http assembly(4.3.2). If I don't install this package manually or install the earlier versions(4.3.1/4.3.0), the application could work fine.
The CreateResponse method is a extension method which is written in System.Web.Http assembly(version 5.2.3). It seem that it is not compatible with the latest version of System.Net.Http. Please could just skip the error by using the earlier version of System.Net.Http and you can also submit this issue to Microsoft using follow channel.
https://connect.microsoft.com/VisualStudio/Feedback
Interesting. For me, if I got above version 4.0.0 (including 4.1.1 or 4.3.1) I still get the same problem of not finding those extension methods.
The assembly might not be updated during you change the package version. From the bin\Debug\net47 folder, we could check the current assembly version we used.
If the modified date of assembly is 2/9/2017, the package version is 4.3.1. If the modified date of assembly is 4/19/2017, the package version is 4.3.2. If the assembly is not the latest version, it could work fine on my side.
In addition, Microsoft.Asp.Net.WebApi.Client package is installed by default when creating an Azure function. System.Net.Http is one of its dependencies. So we don't need to install the System.Net.Http package manually. When running our application, NuGet will choose a right version of System.Net.Http for our application.
I had the same issue running my Azure Function locally and eventually tracked it down to conflicting System.Net.Http assemblies. I created my Azure function from a blank ASP.NET Web App and initially pulled down the System.Net.Http NuGet package to use within the project. I also pulled down the Microsoft.AspNet.WebApi.Client for use within the project. It did not matter which version of System.Net.Http I tried my project would compile but fail when the request was made.
Eventually, I removed packages I had downloaded, cleaned the build folder and added just the Microsoft.AspNet.WebApi.Client. I noticed that this automatically referenced the System.Net.Http on my machine for my version of the .NET Framework. (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework). This compiled successfully and I was able to make requests to the function without any exceptions.
Using #Aaron-Newton's insight, I identified that my issue was due to my Azure Functions project referencing a .Net Standard 2.0 class library. I switched it to .Net Framework 4.6 and it started working again. Seems like this is a bug in the Functions tooling.
I've filed a bug with the Functions team here: https://github.com/Azure/Azure-Functions/issues/477
I had the same issue. I spent quite a while to fix this problem.
The cause is that the Azure Functions project is refering to .Net Standard Library with version higher than 1.4.
Bringing down your .Net Standard version to 1.4 or lower would fix the problem.
But this is defintely a bug with Azure Functions SDK. They should fix it.
https://github.com/Azure/azure-webjobs-sdk-script/issues/980
https://github.com/Azure/Azure-Functions/issues/477

Visual Studio 2015 C# ANTLR

To convince my employers of the benefits of ANTLR and StringTemplate, I constructed a small demonstration first in Java. But Java is not one of our preferred languages, so I translated it to C#. Using VS2015 (Community Edition) and various instructions on the net I got only so far. I now get
ANTLR cannot generate 'org.antlr.v4.codegen.CSharp_v4_5_2Target' code as of version 4.3
Incompatible versions? Which versions of what libraries are compatible for a successful build. I could not work out how to use GitHub. There didn't seem to be a package to download, and I could not see how to download a set of files to compile.
Update 1
Randomly installing versions of whatever I can find, I have now got it down to loads of errors like this from the generated code.
CS0103 The name '_errHandler' does not exist in the current context
Update 2
I have subsequently tried (and failed) to get it going in VS2010(Express). I think that version is seriously hobbled. I can't get NuGet working on it. I am now going to try to install VS2013 as that seems to be the most commonly referred to in this ANTLR context. With VS2015 I have been through all the .NET versions I have installed on my machine back to v3, with no success. It now fails to generate the parsing code.
Update 3 - Solved
Problem solved! Use VS2013 and follow Sam Harwell's clear instructions. Some minor differences between Java and C# to work out when using StringTemplate

Async BCL and .net 4.0

I have a WPF application that targets framework v4.0 and uses async BCL. It seems that installing only .net framework v4.0 on fresh W7 OS is not enough, since as it seems, there was a bug which was corrected with later update. For example, installing update v4.0.3 solves the problem with using async BCL on framework v4.0.
My concern is this: On my developer machine (W8.1) I do not have this update installed (at least it is not registered in windows registry, nor under the windows updates). Still, my application is working just fine, which means that the update is somehow installed through some other method.
The question: how can I know that application that uses async BCL will work correctly on client's OS? Currently, when I install the application (wix 3.8), I check if .net 4.0 is installed, and I check if KB2600211 (4.0.3) is installed (by searching adequate registry keys). If not, I install them, but I am wondering if searching for KB2600211 is the right approach? Is there some other way to make sure that app will work correctly?
On your Windows 8.1 you have .NET 4.5.1 which is an in-place update for .NET 4.5 which is an in-place update for .NET 4.0. That means you no longer have plain .NET 4.0 (.NET 4.0.x, for that matter).
I recommend you to always test on the target environments. It can be as simple as having a VM.

Use of 3rd party libraries/components in production

When using 3rd party libraries/components in production projects, are you rigorous about using only released versions of said libraries?
When do you consider using a pre-release or beta version of a library (in dev? in production, under certain circumstances)?
If you come across a bug or shortcoming of the library and you're already committed to using it, do you apply a patch to the library or create a workaround in your code?
I am a big fan of not coding something when someone else has a version that I could not code in a reasonable amount of time or would require me to become an expert on something that wouldn't matter in the long run.
There are several open source components and libraries I have used in our production environment such as Quartz.NET, Log4Net, nLog, SharpFTPLibrary (heavily modified) and more. Quartz.NET was in beta when I first released an application using it into production. It was a very stable beta and I had the source code so I could debug an issue and there were a few. When I encountered a bug or an error I would fix it and post the issue to the bug tracker or author. I feel very comfortable using a beta product if the source is available for me to debug any issues or there is a strong following of developers hammering out any issues.
I've used beta libraries in commercial projects before but mostly during development and when the vendor is likely to release a final version before I finish the product.
For example, I developed a small desktop application using Visual Studio 2005 Beta 2 because I knew that the RTM version would be available before the final release of my app. Also I used a beta version of FirebirdSQL ADO.NET Driver during development of another project.
For bugs I try to post complete bug reports whenever there's a way to reproduce it but most of the time you have to find a workaround to release the application ASAP.
Yes. Unless there's a feature we really need in a beta version.
There's no point using a beta version in dev if you aren't certain you'll use it in production. That just seems like a wasted exercise
I'll use the patch. Why write code for something you've paid for?
There's no point using a beta version in dev if you aren't certain you'll use it in production. That just seems like a wasted exercise
Good point, I was also considering the scenario of evaluation of the pre-release version in dev, but I supposed that taints the dev -> test/qa -> prod path.
I'll use the patch. Why write code for something you've paid for?
What if it's not a commercial library, but an open source one? What if the patch to be applied is not from the releasing entity (e.g. your own patch)?
I use:
Infragistics (.NET WinForms controls)
LeadTools (video capture)
Xtreme ToolkitPro (MFC controls)
National Instruments Measurement Studio (computational libraries, plotting, and DAQ)
I've found significant bugs in every one of these, so I try to limit their use as much as possible. Infragisitcs is pretty good for what it is, and National Instruments is by far the best, although quite limited. I would avoid LeadTools at all cost.

Resources