I made two functions with matlabe and wanted to make a .net component
I created a new project , added a class , and added files (two functions .m)
but when i'm tring to bult the project i got log warning message and at the end this
error occurs
Invalid .NET framework.
Either the specified framework was not found or is not currently supported.
??? Error using ==> mcc
*Error executing mcc, return status = 1 (0x1).*
There were errors during compilation process.
I know nothing about Matlab but so you have the .Net framework installed? You might need a particular version of .Net, this might be configured in your Matlab environment?
Have a look at this blog post for info on how to set the .Net framework version:
http://itscommonsensestupid.blogspot.co.uk/2009/11/matlab-invalid-net-framework-either.html
The .Net Framework doesn't support any Matlab .m files.
You have to rewrite your matlab scripts by using classes out of the .Net Framework in either C# or VB.Net.
This article looks promising.
Related
I have a project for Azure Functions that has .net standard 2.0 as target framework. This project uses System.Data.Sqlclient to insert and fetch data from a db. It works fine when I deploy it to azure.
To be able to test my code I have created classes in this project that handle the business logic and is setup in the static function that azure executes.
My problem is that when I try to create a class library that is to contain unit tests, I always get an exception that says: System.Data.SqlClient is not supported on this platform. The code runs fine before that. I have tried both .net core and .net 4.6.1 as target framework but no luck.
It worked when I created a new class library with .net core 2 as target. Don't know why it didn't work the first time so unfortunately I cannot tell what went wrong the first time.
I have a Web API application created using .Net Core 2.1. A controller from within this web application calls a Business Layer Class library that I also developed using .Net Core 2.1. So far so good...
The .Net Core Business Class Library references a commonly used .Net Framework 4.6.1 Class Library that we have also developed. This library is primarily used to communicate with Azure service bus queues.
As a result this commonly used .Net Framework Class Library in turn references and makes use of the Microsoft .Net Framework Assembly, Microsoft.ServiceBus as shown in the line of code below.
MessagingFactory messagingFactory = MessagingFactory.CreateFromConnectionString(configValue);
As you can see the line of code above that is within our commonly used .Net Framework Class Library passes a string value (i.e. configValue) to a static method that exists within the Microsoft.ServiceBus assembly.
However, whenever the line of code above executes I get the following Error:
An unhandled exception occurred while processing the request.
TypeLoadException: Could not load type
'System.Web.Configuration.WebConfigurationManager' from assembly
'System.Web, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'.
Out of interest I added in the following line of code which I get the same error:
string configValue = WebConfigurationManager.AppSettings["connectionString"];
Clearly, the issue is that the System.Web .Net Framework assembly isn't loaded.
However, given that the web application is .Net Core then how can I make this web application load the underlying .Net Framework assembly that the commonly used library requires?
Solutions Considered - (Unsuitable)
I had a similar issue before which was easily solved by installing the necessary NuGet package but on this occasion I have not been able to find such a package.
Our team has another Web API application in .Net Framework which calls this commonly used class library without issue however this is not an option and we need to keep the current Web API application based on .Net Core.
I also considered having the commonly used library re-written as a .Net Standard 2.0 Class Library but this given the size of the library this would not be a realistic approach and it won't necessarily address the underlying issue.
Other Possible Solutions
Load a Web.config from within the .Net Core Web API application that contains a configSections section referencing the assembly System.Web. I tried this but it didn't work which I'm sure if I just didn't apply all steps necessary. Is this possible and if so any suggestions?
Is there an alternative way to load the .Net Framework assembly from within the .Net Core Web API?
Sacrifice using the commonly used library and find an alternative (sample) code base that provides similar functionality (i.e. make use of Microsoft.ServiceBus to work with our Azure queues) but that is either .Net Core or .Net Standard based. But similar to the .Net Standard solution above I am unsure how much functionality would need replicated and also unsure of a starting point. Thoughts?
Thanks!
I had the same issue and after investigating i found that my azure function app run time version is 2.0 ~ and according to documentation version 2 is .NET Core 2 and function app version 1.0 ~ is .NET Framework 4.7 . and my visual studio function app project have .NET Framework 4.6.1 . So, I just had to change my function app version to ~ 1.0 .
In a Nutshell
If you have visual studio function app in .NET Core 2.0 then only use function app version 2.0
If you have visual studio function app in .NET Framework 4.7 then only use function app version 1.0
I have two computers.
I was working with computer one to make a prototype of a project. I have created a .NET Standard 2.0 class library and added a .NET Framework 4.6.1 class library. I have referenced .NET Standard to .NET Framework and everything was working.
Now I've switched to computer two and done the same. There was no problem with referencing but I cannot use classes from .NET Standard project. The code is red and Resharper keep telling me
"Reference XX ( .NET Standard ) and use XX "
This gives me no result and, when I add 'using' statement with the .NET Standard namespace the code is still red.
Do I need to download something?
I have a somewhat convoluted issue where I need to call a WCF web service from a SQL Server 2005 stored procedure.
While researching I discovered that the only version of .NET SQL Server 2005 will natively support it 2.0 - yet I needed to use a client to consume the web service written for .NET 4. After playing around with some workaround to try to get SQL Server to recognize a .NET 4 DLL I decided to simply create a .NET 2 CLR stored procedure and use a wrapper class written in .NET 4 exposed as COM in order to call my web service.
I found several guides dealing with how to use a .NET 4 dll with .NET 2 as a COM dll (link, link) yet am still struggling.
My "wrapper class" (.NET 4) looks like this:
namespace Wrapper
{
[Guid("4C1D992C-4965-49B2-A694-33810A3B9775")]
[ComVisible(true)]
public class WrapperClass
{
public bool Process(Guid ID)
{
}
}
}
I've added the app.manifest file as suggested by the second link above. However, when I add the generated DLL to my .NET 2 sql server project, it fails to build with the following message:
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): Warning: MSB3274: The primary reference "Wrapper" could not be resolved because it was built against the ".NETFramework,Version=v4.0" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v2.0".
What am I doing wrong here? I tried not adding the DLL as a reference at all but then the code does not even compile.
Alternatively, is there another (easier) way I can approach this issue?
EDIT: I can't directly add a web reference either:
I ended up just using John Koerner's suggestion and generating a client using WSDL that didn't use System.ServiceModel. As a result I made my CLR assembly .net 2.0 and it worked fine.
I've a C# class with CorePoll namespace, I compiled it to .DLL file and put it inside bin folder of website. But I cannot use it. Imports CorePoll returns Could not load file or assembly 'CorePoll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
It's my class file in C# http://pastebin.com/JkdrnXyT
The message An attempt was made to load a program with an incorrect format., typically comes from mixing 64/32 bit environments. When you build your .DLL, make sure to select Any CPU as the Target CPU int the build settings. That way, the DLL should work no matter if the website is running 32 or 64 bit. But be aware, the message also states Could not load file or assembly 'CorePoll' or one of its dependencies., meaning that if you've referenced other libraries in your DLL, they could be failing to load as well.
Edit: After looking at the documentation, another potential cause of this exception is mixing projects built with different versions of the .Net Framework. Is this possibly causing your error?
Components have been created using different versions of the .NET Framework. Typically, this exception occurs when an application or component that was developed using the .NET Framework 1.0 or the .NET Framework 1.1 attempts to load an assembly that was developed using the .NET Framework 2.0 SP1 or later, or when an application that was developed using the .NET Framework 2.0 SP1 or .NET Framework 3.5 attempts to load an assembly that was developed using the .NET Framework 4. The BadImageFormatException may be reported as a compile-time error, or the exception may be thrown at run time.
None of answers helped me, I converted the C# code to VB.NET and used it with no problem, thanks for your time.