Visual Studio 2010, using VB.NET. Intellisense does not recognize new property until I recompile - vb.net

I have an ASP.NET VB.NET web project that references a VB.NET class library.
I add a new property to a class in the class library, then, from the web app, I expect to be able to use it immediately w/o errors and with full intellisense.
It used to work in 2008.
When I compile the class library, it becomes available but not until.
Was this nice feature taken away, perhaps in the interest of speed?

What's likely happening here is that the Class Library and ASP.Net applications are targeting different versions of the framework. If they are using incompatible versions of the framework then VB.Net will treat it as a file reference instead of a project reference and would give you the behavior you're seeing.
Right click on the project, select the Appilication Tab and make sure that both have the same value selected for Target Framework. That should fix the problem.

Visual Studio 2010 will officially launch on April 12, 2010. I'd say there's a good chance that problem will be fixed in it. Go see.
EDIT: corrected the date.

Related

Why I can't use Shell method in VB.NET?

I see everyone is using the Shell command without any problem, but it doesn't work for me, it says it's not declared like it doesn't exist. I'm working in Visual Studio using VB.NET.
Interaction.Shell is in the Microsoft.VisualBasic namespace, which should automatically be imported for Visual Basic projects.
If it isn't in yours, you can fix that in the project properties (Tab "References") or manually add Imports Microsoft.VisualBasic at the top of the code file.
Another possible reason is that Interaction.Shell is not included in .NET Core versions prior to 5. In that case, use a "classic" .NET Framework project or .NET 5 or higher instead. (Credit to Hans Passant in the comments.)
I have recreated the app, without change anything and now it works... In any case, thank you to everybody for the support.

"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

GetActiveObject is not a member of Marshal

I'm working in vb.net in Visual Studio 2017. I'm fairly new to visual basic. I'm more familiar with VBA.
I prototyped code to access Autodesk Vault 2019, download a file, and open it in Autodesk Inventor 2019. This code was created with an Autodesk Inventor AddIn template in visual studio. The code compiled without errors and functioned as intended.
The final intention of this application is to compile the code to a DLL and then call that DLL (with arguments) from VBA in another piece of software (CorelDraw). In order to do this it is my understand that I need to place the code in a class library template in order to have it compile to a DLL correctly.
While doing this, I have an issue with the following line of code:
ActiveInvApp = Marshal.GetActiveObject("Inventor.Application")
"Marshal" is from "System.Runtime.InteropServices" which is imported at the beginning of the application with the following line of code:
Imports System.Runtime.InteropServices
The issue is that Visual Studio doesn't recognize "GetActiveObject". It highlights it with a red squiggly line. When I hover over it with the cursor it shows the tooltip: "'GetActiveObject' is not a member of 'Marshal'".
At the time of writing this I have two instances of Visual Studio 2017 open. One with the class library version of this code and one with the Autodesk Inventor AddIn version. The AddIn version does not have a problem with this line of code and the class library does.
Per some instructions on creating a DLL class library, my code starts with the following:
Namespace VaultCOMFunctions
Public Module StringLibrary
<Extension>
Public Sub OpenFromVault(PartNum As String)
'Code for opening the file goes here
I'm not sure if that's relevant or not. Like I said, I'm somewhat new to VB.net.
I've spent a good deal of time messing around with references to try to clear this up, but with no luck. What could be causing this? I can't find any existing forum posts (here or elsewhere) with any kind of a similar issue.
The answer was posted by #Simon_Mourier in the comments on the original post. The Visual Studio project was targeting .NET Core. To fix the issue I simply switched the project to target .NET Framework and the error went away.
Check the version of .NET Framework you are targeting. GetActiveObject was removed after .NET 4.8.
https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.getactiveobject?view=netframework-4.8

VB 14 missing from Visual Studio 2015

I have Visual Studio 2015, but can't get the new VB language features to work. Or to show up. It's like the product came without it. The null-coalescing operator doesn't work, read-only auto-properties aren't allowed, etc. This is true even when I set up a brand new project, targeting any version of the framework (which shouldn't matter, but I'm trying everything I can think of).
I've got Resharper 9 installed. Following a suggestion in this question, if I select the project, the VB Language Level dropdown list doesn't show anything more recent than "Visual Basic .NET 12".
There are no LangVersion tags anywhere in the .vbproj files. If I add them it seems to make no difference.
I was under the impression that you didn't have to install anything separately for VB 14, just use VS 2015 and you'll have it (C# 6 actually is available and working in C# projects) but it's not there.
Anybody have any ideas what else I can look for?
It's Resharper.
I'm using Resharper 9.2 Ultimate. Resharper is what's putting all the error messages into the code editor. If I suspend it, all the problems go away, and the code compiles and runs exactly as it should.
I should have taken a cue from the fact that the VB Language Level isn't showing the latest version of VB.
Off to contact technical support.

Migrating project from .NET 2.0 to .NET 4.0

I'm migrating my solutions from .NET 2.0 to .NET 4.0. I open the solution file in VS 2010 and follow migration wizard.
While building the solution and comparing the changes with the server copy (since solution is under source control VSTS), I surprisingly found that
1) the public classes were changed to 'internal' and
2) the 'public static' properties were changed to 'internal static'
It gave me problem because the output assembly is referred in other projects.
Can someone explain why does it happen? Also, are there any other such changes taking place behind the scene? Or Am I doing something wrong ?
(Note: I have ReSharper 5.1 installed but I think it has no place in this case.)
ReSharper may have given the suggestion to make methods static for those methods which are not using any instance variable or method within it. This is what I have observed.
Similarly, if the methods are not accessed from any other project/assembly, it may give you suggestion to make them internal.