I'm wondering what the best way to "Modernize" a VB.NET webservice is. I have a traditional webservice written using the System.Web.Services.WebService class in a old school website project.
<%# WebService Language="VB" CodeBehind="~/App_Code/JsonService.vb" Class="JsonService" %>
Assuming I can break the webservice into it's "own thing/API" that doesn't have a front end coupled with it, I would like to be able to run this in AWS Lambda or Docker etc.
What would my options be? Some things I can think of:
Re-write everything in C# in a .NET Core project
Somehow use VB.NET and .NET Core/.NET 5 at the same time? (I don't know how to do this, I think .NET core only supports C#?)
Use a "code converter" for the vb.net files, which the support seems pretty bad for at the moment.
I can read VB.NET code decently, but I am by no means an expert.
Here's a C# net5 web API project referencing a VB.NET net5 class library project, getting the VB to produce the value. You than thus leave most of the logic/objects in VB, and have the C# be a thin proxy for the logic. The debugger will step back and forth between c# and VB without complaint. You can gradually port over the VB if you want
ICSharpCode's VBNET converter is pretty good; gives a helpful start to any conversion at least. You'll learn the usual gotchas; VB using () for array indexers and methods, for example; converters don't always get that one right..
Related
Since VSTO has yet not been ported to .NET Core, can I do it the old fashioned way and create a unmanaged shim to load the CLR and host the managed .Core 5 add-in?
My particular use case is an Outlook COM add-in that is currently built using VSTO against .NET framework 4.7 but I want to start leveraging .NET 5. In terms of interaction with Outlook, it just adds some buttons on the Ribbon and makes a few calls into the Outlook object model. I don't need to do anything like VSTO document based add-in in Excel for example.
I don't want to down the JS path as there is quite a bit of C# code that would need to be ported.
I found this https://github.com/jozefizso/COMShimWizard/releases which shows how to do it with the .NET framework, and am assuming its pretty close if not identical to what the shim wizard did back in VS 2010.
Since I need to load .NET 5 I believe to load the CLR I will need to do something along the lines of what is outlined here: https://learn.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting.
Before I dig further into it, is the approach likely to work? In particular, will in be possible to do necessary COM gymnastics to instantiate the managed components?
And assuming all this is feasible, will this be more or less equivalent to what VSTO does for .NET framework 4.x, i.e. is it less safe or performant in any way or will there be any functionality that won't be available compared with an add-in built with VSTO?
Update 1
I did some more research which raised some additional potential issues.
For the .NET framework case, once a class has been loaded into the CLR it is relatively easy to "unwrap" the returned reference to get a COM pointer which can be used to access COM interfaces that the type implements. It is not clear to me how this can be done when loading the .NET Core runtime using netfxr interface.
.NET Core does not have the concept of app domains, does that mean the multiple add-ins loaded into the Core runtime would not be isolated, or there a way to achieve some degree of isolation? From what I have read it seems that maybe their heaps would at least be isolated but I'm not sure.
Update 2
From reading this https://github.com/dotnet/runtime/blob/main/docs/design/features/COM-activation.md it seems that in Core, requests to types in assemblies as COM servers will result in auto loading the Core runtime (if it isn't already loaded) and create the object in a separate AssemblyLoadContext so maybe a shim is not needed at all? On the other hand it seems that if the Core runtime is already loaded and the version does match what is required by type you are trying to create, then the type will fail to load, so that seem to be a problem...
I am refactoring some code and am working with another programmer. I suggested refactoring the code to follow the MVC pattern to remove all the plumbing from the forms code and put them into seperate classes such as a controller and model class for database. He disagreed with me saying that VB is not meant for MVC and that we should put the code into DLL's. I agree with DLL's but put the MVC into the DLL's is my opinion. Have I got the wrong idea ?
It is a desktop application? because in that case it would be more useful a pattern of MVVC. In any case, I recommend that you seek information from Domain Driven Development (DDD). Here's an article from a practical example =>http://www.codeproject.com/Articles/768664/Introduction-to-ASP-NET-Boilerplate
I am building an application in VB (VS2012) and the main code is written in Matlab. I would like to call the Matlab scripts from the VB form and also display the results of the calculations in the VB form in a datagrid. Can somebody suggest what my mode of exchange should be?
Thanks for the help.
You have two main options.
MATLAB has a COM interface. From VB, you can start an instance of MATLAB, pass data to it, execute commands, retrieve results, and quit MATLAB. To find out more, take a look at the documentation pages for the MATLAB COM Automation Server. This method will require you to have a live copy of MATLAB present when you run your VB application.
You can use an add-on product to MATLAB, MATLAB Builder NE for .NET (you'll also require another add-on that it depends on, MATLAB Compiler). MATLAB Builder NE allows you to convert your MATLAB code into a standalone .NET assembly or COM component that can be called from your VB application, and distributed with it.
Note that contrary to a comment, MATLAB Compiler alone without MATLAB Builder NE does not allow you to produce .NET assemblies.
I need to use REST web services under Windows Phone 8, but there is no System.ServiceModel.Web namespace in WP framework so I cannot use WebGet and WebInvoke annotations.
How am I supposed to do HTTP GET calls using WCF? Is WCF supported in Windows Phone 8?
EDIT
The only approach that I can think off now is to use direct approach using HttpWebRequest and handle everything by hand. I wanted to avoid this since this approach brings too much boilerplate code inside the production code. This is why WCF is here. I can't even use RealProxy to implement some basic facilities myself since it's not supported either. The only solution that brings some automation and removes boilerplate code is to use dynamic and DLR features with DynamicObject, that will resolve the calls in runtime, but this will strip me of from static compiler checking.
Why did Microsoft remove crucial parts of framework from WP8? I don't get it.
Why did Microsoft remove crucial parts of framework from WP8?
They were never present. Such APIs would be considered features. And with frameworks like RestSharp there's little need to trouble yourself with writing anything by hand.
Has anyone developed or know of a place where I could find a Silverlight implementation of NetDataContractSerializer?
This WCF and Silverlight Comparison states that Silverlight does not ship with an implementation of NetDataContractSerializer.
I'm hoping to avoid developing one myself.
Thanks!
I might be wrong, but I think the Silverlight version of CSLA includes some form of binary serializer. It's not compatible with NetDataContractSerializer I think, so you'll need to use it on both the server and client (CSLA comes in a Windows flavour too). You can get the full framework (with source) for free at http://www.lhotka.net/cslalight/