.net - Type Is not defined - C# class to VB.NET -
i sitting rather strange error - believe followed correct steps solve.
basically, compiler complains following:
type 'interactionsentities' not defined
here explanation of have done. goal use class compiled in c# within vb.net project.
step 1: right clicked vb.net project - add > reference
step 2: out of project list, selected c# project containing interactionsentities
class , pressed ok.
step 3: added line of code in vb.net module: imports csharpproject.csharpnamespace
step 4: within module, added variable: private context = new interactionsentities
-- note on point, intellisense able find class required.
step 5: ensure project can use entity framework, used nuget package manager install entity framework.
so following steps listed above, have following code:
imports csharpproject.csharpnamespace module module1 dim context = new interactionsentities() sub main(properties string()) dim documents = context.documents.select(function(x) x) each document in documents console.writeline(document.name) next end sub
what strange intellisense able detect interactionsentities existed in c# namespace. upon installing entityframework nuget package, error disappear - , able access properties within context variable. moment hit "rebuild all" - error type 'interactionsentities' not defined
returns. hovering on namespace (which gets marked erroneous now) , clicking error corrections options
yields no correction suggestions.
have missed step inbetween? why vb.net project complaining class not exist when does? have tested other classes under c# namespace (which has nothing entity framework) , same effect occurs.
wow ok. found problem.
when happens, ensure c# project , vb.net project @ least compiled in same .net framework version.
my inspection in project following:
- right-click c# project > properties > application > @ target framework (my case 4.5.1)
- repeat steps vb.net project > properties > application > @ target framework (my case 4.5)
- set .net framework of vb.net project match of c# project , click yes in dialog box pops up.
- rebuild project
this fixed issue.
Comments
Post a Comment