Type 'MarshalAs' is not defined
Here is an example of the code that is causing the error:
<StructLayout(LayoutKind.Sequential)>
Friend Structure VersionInfoDef Dim SizeofVersionInfo As ByteDim BootVersion As VersionDef
Dim OSVersion As VersionDef
Dim NumOSExtensions As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=40)> Dim OSExt() As Byte
Public Sub Initialize()
ReDim OSExt(39)
End Sub
End Structure
I have tried every Imports statement I can think of. Here is what I have now...
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.UnmanagedType
Imports System.Runtime.InteropServices.Marshal
Imports System.Runtime.InteropServices.StructLayoutAttribute
I also notice that when I click on the error in the error list, it does not take me to the error even though it shows a line number with the error.
Thanks for your help..
Clark

Error Type 'MarshalAs' is not defined
Steve Roszko
Josh Pendergrass
Intellisense is working the same for me too. The error happens when I try to compile. Since you can compile ok, it is clear that I will have to repair VS, reinstall VS, or kill my computer.... HA!
Thanks for your help!!!
Clark
Hugo Flores
Thanks for your reply. When I change my code to your code I get another error "Type 'Runtine.InteropServices.MarshalAs' is not defined. I am now getting this error on this structure instead of the previous error. It seems that Runtime.InteropServices is messed up.
Is something wrong with my installation of VB2005 or is this a bug
Clark
Tom Albrecht
krissmith
I also just to confirm type in "<Runtime." and intellisence picked it up after that for interopservices and MarshalAs. So I am going to say its your enviorment.
Joe Szymanski
Just a couple of last followup questions, wacko...I didn't totally understand what you were saying at the start of your first post....with respect to Imports.
Are you saying you have this imports statement in your program...
Imports Runtime.InteropServices.MarshalAs
When I try to enter that, there is no MarshalAs available after InteropServices. I only have Marshal and MarshalAsAttribute. Does your system behave this way Is your system different than mine I have tried imported both Marshal and MarshalAsAttribute....neither helps.
Thanks again for taking the time to try to help me. Unless I can quickly find what is wrong with my system, I guess I will reinstall VS2005 on a clean machine and see what happens.
Clark
Michael Friedman
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> Friend Structure VersionInfoDef
Dim SizeofVersionInfo As Byte
Dim BootVersion As Version
Dim OSVersion As Version
Dim NumOSExtensions As Byte
<Runtime.InteropServices.MarshalAs(Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=40)> Dim OSExt() As Byte
Public Sub Initialize()
ReDim OSExt(39)
End Sub
End Structure
ez.xcess