Calling Trimble Connect APIs from a C# App - c#

I am trying to use a C# application to interact with a Trimble Connect Project. To do this, I'm trying to follow this link: APIs tutorial.
The problem is that after adding a lot of missed dependencies I'm stuck with this:
Could not load type 'System.ServiceModel.Description.DispatcherSynchronizationBehavior' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

This problem is becasue you are trying to build this application using .Net Core framework. .net Core core 5.0 framework did changes on ServiceModel along with other. You can refer this link
Here how you can use application. As per documentation of SDK, they supported .Net Framework 4.0 and onwards. Hence you need to use VS 2017 with framework 4.6 or 4.7. Here is the sample running application code from github. you can download this application and open in VS 2017.
You can also download other running code based on different targets from here. Incase you are strugging with Trimble, you can write mail on 'connect-integrate#trimble.com'

Related

Microsoft.Extensions.X Version 7.0.0 Issue - .NET 7 FunctionApp

I've just started upgrading my functionapps to .NET 7. I've updated them all to use the .NET 7 SDK and all of the Microsoft.Extensions.X deps in my project to 7.0.0.
I'm getting this error:
Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. .
Having had similar issues when upgrading to .NET 6, I had to upgrade my functions to the V4 runtime.
However, they're already on the V4 runtime and this table suggests that V4 supports .NET 7.
Is this a case of Microsoft just not having updated all of its function runners or am I missing something?
The Table of which you have shown providing the general details like Compatible Runtime Languages & Versions with Azure Functions but not the In-Process or Out-of-Process Type.
Current month Update - .NET 7 in Azure Functions is supported by leveraging the .NET Isolated Worker process. as mentioned in this Microsoft TechCommunity article
If you click on the .NET 7.0 shown in the same table, you will see another table like .NET 7.0 came in Isolated Worker Process.

using vb dll in .net core 3.1 project

I have a.net core 3.1 Web API project and I have to use functions from a dll programmed in vb.
and I am not allowed to modify the dll.
when running the service,I get the error:
"Could not load type 'Microsoft.VisualBasic.Devices.Computer' from assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=fghda'.",
I tried addind this dll in .netframework web API project and by adding "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" nuget to the references ,I could successfully run the service.
the problem is this nuget is not working in .net core and using similiar nugets were useless.
I also added microsoft.visualbasic dll but nothing changed.
So anybody knows how to resolve the issue?
.NET Core still does not seem to support VB .NET. It was mentioned in the previous statement that it will be supported in the future.
https://devblogs.microsoft.com/vbteam/visual-basic-in-net-core-3-0/

TypeLoadException Could not load type 'WebConfigurationManager' when calling .Net Framework Library via Web API Core app

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

Could not load file or assembly - Framework .NET 3.5

I'm facing a compatibility issue for .NET project.
I have 2 projects:
1st project: Libary project. Target: windows Phone 7.0 OS version
project
2nd project: Console Appplication project. Refers/use the previous
library. Target: Framework .NET 3.5
When I try to run the 2nd project, I have an exception that happens when I call a function from the 1st library:
...Could not load file or assembly 'System, Version=2.0.5.0,
Culture=neutral, PublicKeyToken=7xxxxxxxx or one of its dependencies.
The system cannot find the file specified...
If I change the target for 2nd project to Framework .NET 4.0, it works well, no more crash.
Is my error really due to the different target versions ?
How can I make the 1st project to be compatible with framework 3.5 ?
As I said, 1st project was targeting framework 3.5 .NET and 2nd project was targeting Windows Phone 7.0.
Work around: change 2nd project to target framework 3.5 .NET. (in my case, I add to create a new project in my solution, which in fact was the same as the old one but targeting framework 3.5 .NET. Same sources used.)
Kindly rough but works.
I had excactly same issue. Installing Portable Class Library helped me.
https://msdn.microsoft.com/en-us/library/gg597391.aspx
There are links to downloads for different visual studio versions.

How to embed .NET Framework 4.0 into c# project

I make a c# application project. this project run on my computer good, but in other computer says you must first install .NET Framework 4.0 to run this application.
How to embed .net framework 4.0 into c# project.
Thanks
You can't embed the framework into your application sine it needs to be installed on the client machine (not just xcopy'd like your app).
You'll need to create an installer which will take care of detecting and installing the required framework version before installing your application.
There is a tutorial here which shows how to create a setup project.
Once everything is set up, go to Project > [project name] Properties, click the Prerequisites... button and check .Net Framework 4. By default, the setup will download the Framework from Microsoft, so it will need an internet connection.

Categories

Resources