Can Visual Basic run as a Windows Service? - vb.net

I am less than a week into my Visual Basic education. I have downloaded Visual Studio 2008 and am teaching myself Visual Basic 2008 in hopes of landing a particular contract position.
In the meantime, a friend of mine told me that it is not recommended to write a Windows Service with Visual Basic. Is that true? Could he be referring to some much older version than 2008? Does the .NET version come into play?
What is at stake is that the company that my friend works for is going to completely re-write a component of their flagship product at great cost and expense and simply abandon their existing VB code. If the only hang-up is getting it to run as a service then they could save a lot of money if Visual Basic could, in fact, run reliably as a service.

You can write .NET services in any CLR language, including VB.NET --- your friend was thinking of VB6 and earlier.
(I do recall some fairly crazy kludges that allowed services to be written in VB6, but for all practical purposes, services written in VB6 weren't really a viable solution...)

There is no reason that Visual Basic .Net can't write a windows service. You can select a project which will create a windows service under the "Windows" projects in the Visual Basic section.

Writing a Windows Service in VB.NET (using any version of Visual Studio >= 2003) is just as effective as writing a Windows service in any other language.
Your friend may have been thinking of Visual Basic 6...or he's partial to another .NET language.
In either case...you should be fine to keep going on your path the way you are.

Your friend may be referring to Visual Basic, not VB.NET.
While VB.NET has syntax that is similar to Visual Basic and some convenience functions are still present, they are two entirely different languages and environments.
Your friend is correct in stating that Visual Basic (meaning 6 and earlier, not VB.NET) is a poor choice of a language for a service (or any new application), but VB.NET is every bit as legitimate as C# or any other CLR language.
It may be useful to refer to what you're learning as "VB.NET" or "Visual Basic .NET", rather than just "Visual Basic".

.NET certainly allows you to use Visual Basic to write a Windows Service. I believe there is even a default project template to do so. Here is an tutorial as such: http://www.vbdotnetheaven.com/UploadFile/mahesh/Winservvb11172005233242PM/Winservvb.aspx
All .NET code is converted to an intermediary language that is executed, thus all .NET languages can be used to write a windows service.

Related

"Could not resolve mscorlib ... .NETFramework,Version=v2.0" in VS2015 from VB6

My question is similar to others, but my particular nuance of this problem doesn't appear to have an answer I can find on here so far, so here goes. (edits in italics)
Our company has a deployed application written in VB6. Since VB6 development is no longer officially supported in Windows, our company made the decision to port our VB6 application to VB.NET.
(Prior to this edit, I had mentioned that the project was converted to VB.NET using VS 2015. This was incorrect, I discovered that my coworker had actually performed the conversion using VS 2008, and I was working on the 2008 project in 2015.)
So we are now working with the VB.NET conversion in VS2015. As many of us know, the VS 2008 converter does an incomplete job porting VB6 code to VB.NET code so there are many, many errors to sort through (as of this writing, all compile errors are fixed). In particular, though, I'm trying to open the various forms for the project in the Designer so I can see and work with them. The designer specifically is reporting the error:
Could not resolve mscorlib for target framework '.NETFramework,Version=v2.0'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.
I saw some mention of a 256 character limit on dependency paths. This dependency is met in my case. I have also confirmed that .NET Framework 2.0 is installed and active in my instance of Windows. I have seen the recommendation to upgrade the .NET Framework version as well, which was successful in itself but did not resolve this mscorlib issue.
Full call stack for this error follows:
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)
at Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()
at Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type type)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
How can I gain the ability to view my project in the Designer?
As far as I know, opening VB6 files in VB.NET will not work. You will have to make modifications in Visual Studio 6.0 or re-write the application in VB.NET/C#.
Older versions of Visual Studio (until 2008) had some converters but they never really worked as expected.
You can take a look at Visual Basic Tools for Visual Studio, it "allows to work with classic VB workspaces and projects within Visual Studio.", this will allow you to modify the VB6 project in a newer version of Visual Studio but the code will remain VB6.
Regarding your exact issue, others have reported that the following worked for them:
Remove and add back project references that have warnings.
Rebuild the project
Remove and add back Microsoft.Office.Core
Good luck!
As someone who has converted a number of VB6 applications to VB.Net, I always advise a full rewrite. The languages are just too different. You waste far too much time trying to resolve issues of this type.
Better still, just leave the VB6 application running as is.
Microsoft's VB6 support statement

visual studio 2010 with c# like namespaces in vb

Is it possible to have visual studio 2010 automatically add namespaces to classes within folders just like c#?
No this is not possible with the VB.Net project system. I would encourage you to share this opinion with the Visual Basic IDE team. They closely monitor suggestions and I know this has come up in the past (although I don't know if there is a current outstanding request for it).
http://connect.microsoft.com

Does Mono support visual basic (not .NET)?

Someone asked me today if it was possible to port a visual basic application to Linux or similar platform, I assumed it was .NET so I suggested to use Mono, but noticed that on their vb support page they only talk about vb 8 (.NET)
Does mono support non-.NET vb? In fact I'm not sure what he is using, I think vb6, I'm not sure of the versioning at all though.
No, VB6 is an entirely different beast from VB.NET. Mono is basically there to run (via JITting, interpreting or AOT-compiling) IL - the Intermediate Language that VB.NET and C# compile down to. (Of course it also provides the libraries and compilers.)
Running VB6 requires an entirely different execution environment, basically.
No, but you could take a look at gambas
Gambas is a free development
environment based on a Basic
interpreter with object extensions, a
bit like Visual Basic™

Active X Development: VC++ or VB or Other technologies

We are in the process of creating active-x controls used within our application.
Since Microsoft stopped supporting classic Visual Basic, is it wise to use Visual Basic to develop the Active X control or the latest VC++/ATL/MFC libraries provide more feature where we can create controls faster by leaving Visual Basic flexibility?
We will not be able to use .NET/VB.NET/C# since the application is supposed to work inside containers and containers may not support latest .NET runtime.
Any other language is best fit for Active X control development other than VB and VC++?
I, personally, would recommend using Delphi for this. It is still actively developed, and has the control you get with C++, but a rapid development environment more like VB.NET.
#nobugz: If you are really interested what is ActiveX in Delphi, look at docwiki. Normally it is 100% source code (yours + VCL, VCL is also available as sources) with autogenerated COM wrappers. So all potential security problems are also in source code. If you find a security problem in VCL, please send a bug report to Quality Central.
Here is a good example on how to create ActiveX Controls with C# .NET
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
By all means VB6 is the best language. After reading your question I feel that you are a VB6 developer. If you know VB6 and use it then why hesitate using it for producing ActiveX controls.
I program in Delphi as well as VB6 along with VB.NET and C# but creating ActiveX controls is the easiest in VB6 compares to all other development tools.
If you are hell bent on not using VB and if you are looking for an alternative then try out PowerBasic (commercial - very costly) or PureBasic (commercial but affordable) Get it from here or better still MinGW (a GNU C++ compiler).
I have to say that VB6 with a good book like Developing COM/ActiveX Components with VB6: A Guide to the Perplexed you will be up and running faster.

Delphi to Visual basic conversion utility

Is there any code conversion tool for converting Delphi to Visual Basic? Please advice.
Thank you very much.
Not that I'm ware of. There are tools to convert Delphi to C# or Visual Basic to Delphi. But not the other way around. It's probably because Delphi has a lot more features then Visual Basic to make it a difficult transition.
You can do it by hand. But it'll take a while.
If you consider moving to VB.NET (and .NET platform in general butnot VB6), these questions might give you some ideas/options:
What tools exist to convert a Delphi 7 application to C# and the .Net framework?
Is there an easy way, to Port a Win32 App in Delphi 2009 to .NET ?
Migrating a Delphi 7 application to .NET
Delphi to .NET + C#
Delphi’s interoperability with .NET
You can try migrating the application from Delphi (Win32) to Delphi.NET or Delphi Prism
Once this step is complete you can consider migrating to VB.NET or C#
But it really depends on the technologies used by your original application (e.g. BDE, 3rd party components), level of interaction with WinApi and so on.
Delux Software has one.