Click here to Skip to main content

Visual Studio

    RSS: RSS Feed

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
AnswerRe: win32 exe unhandled exception "memory could be read" PinmvpLuc Pattyn11:24 23 Nov '09  
GeneralRe: win32 exe unhandled exception "memory could be read" PinmemberAsh_VCPP21:36 23 Nov '09  
GeneralRe: win32 exe unhandled exception "memory could or couldn't be read" PinmvpLuc Pattyn22:58 23 Nov '09  
QuestionVSTFS Help Pinmemberarvindcoolest20:36 19 Nov '09  
AnswerRe: VSTFS Help PinmemberRobin_Roy16:37 22 Nov '09  
QuestionLoad Report PinmemberL_K8:13 14 Nov '09  
QuestionInvalid Cast Exception Occurs when changing target cpu option in VS. PinmemberTapsnapper11:09 11 Nov '09  
I've written a routine that gets the windows installation key from the registry. This routine is just one part of a bigger application that I'm building. However, I have a problem with the routine not running correctly when Visual Studio's Target CPU option is changed from AnyCPU to x86. Note: I'm running a 64bit OS, but I want the app to specifically target 32bit platforms.
 
When VS is set to AnyCPU the routine works fine. When set to x86 an invalid cast exception of "Unable to cast object of type 'System.Int32' to type 'System.Byte[]'" occurs at the DirectCast line.
 
 Dim aryDigitalProductID As Byte()
      Dim objDPID As Object = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "DigitalProductId", 0)
 
      If objDPID Is Nothing Then Return "Not Available"
 
      aryDigitalProductID = DirectCast(objDPID, Byte())
 
I'm using the directcast because I prefer to code with Option Strict set to on. However, if I turn Option Strict off, and coerce objDPID to an array the invalid cast exception still occurs.
 
Does anyone know how to overcome this so the routine would work when targeted specifically at a 32bit platform?
 
Also, when the AnyCPU option is selected, how does the compiled AnyCpu code differ from x86 code?
 
Any help would be greatly appreciated. (As you can probably infer, I'm not completely au fait with VB.Net and VS.)
AnswerRe: Invalid Cast Exception Occurs when changing target cpu option in VS. Pinmemberjessemtcarlton6:55 3 Dec '10  
GeneralRe: Invalid Cast Exception Occurs when changing target cpu option in VS. PinmemberEuhemerus7:59 3 Dec '10  
GeneralRe: Invalid Cast Exception Occurs when changing target cpu option in VS. Pinmemberjessemtcarlton8:06 3 Dec '10  
QuestionConfiguring Visual Studio 2008 Help Pinmembersoftwaremonkey7:42 10 Nov '09  
AnswerRe: Configuring Visual Studio 2008 Help PinmemberRichard MacCutchan7:52 10 Nov '09  
Questionvarbinary(max) Visual studio 2008 PinmemberSchalk Munnik8:26 8 Nov '09  
Questionfile upload Pinmemberbahar.ghara1:52 7 Nov '09  
AnswerRe: file upload PinmemberRichard MacCutchan5:17 7 Nov '09  
AnswerRe: file upload PinmvpLuc Pattyn5:24 7 Nov '09  
GeneralRe: file upload PinmvpChristian Graus9:53 7 Nov '09  
Questionabout unable to connect to visual studio local host web server Pinmemberabolibapat722:04 6 Nov '09  
QuestionOpening Partial Class files Pinmemberkeefb0:37 6 Nov '09  
AnswerRe: Opening Partial Class files PinmvpLuc Pattyn4:43 6 Nov '09  
GeneralRe: Opening Partial Class files Pinmemberkeefb5:02 6 Nov '09  
GeneralRe: Opening Partial Class files PinmvpLuc Pattyn5:07 6 Nov '09  
QuestionAAHHH #if/else/endif placement in Visual Studio PinmemberMike Marynowski0:03 5 Nov '09  
AnswerRe: AAHHH #if/else/endif placement in Visual Studio PinmemberRichard MacCutchan0:26 5 Nov '09  
GeneralRe: AAHHH #if/else/endif placement in Visual Studio PinmemberMike Marynowski0:32 5 Nov '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.5.120210.1 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid