Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:51:13+00:00 2026-06-04T11:51:13+00:00

I can get this code to run in the interactive environment but it crashes

  • 0

I can get this code to run in the interactive environment but it crashes when I run the code from debugger or from the .exe file

Forgot the error:
FatalExecutionEngineError was detected!
The runtime has encountered a fatal error. The address of the error was at 0x6c9781b0, on thread 0x1104. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Using .net 4.5

open System.IO
open System.Runtime.InteropServices
open System.Text

[<DllImport("kernel32.dll",CharSet = CharSet.Auto, SetLastError=true)>]
extern uint32 GetShortPathName(
    [<MarshalAs(UnmanagedType.LPWStr)>] string longpath, 
    [<MarshalAs(UnmanagedType.LPWStr)>] StringBuilder shortpath, 
    [<MarshalAs(UnmanagedType.U4)>] uint32  item)

let MakeShortName(longPath : string) =
    let sb =  StringBuilder()
    let currPath = longPath
    let item = 1024u

   // let blah = ""
    //win32 assigns shortPath
    let blah32 = GetShortPathName(currPath, sb, item)

    sb.ToString()

[<EntryPoint>]
let main argv = 

    let path = @"C:\dev\shortName\shortName"
    let shorty = MakeShortName path
    printfn "%s" shorty 
    let x = System.Console.ReadKey()

    0

Interactive env


$ (me alt+entering the above two functions)

val GetShortPathName : string * StringBuilder * uint32 -> uint32
val MakeShortName : string -> string

$ MakeShortName @”C:\dev\shortName\shortName”;;
val it : string = “C:\dev\SHORTN~1\SHORTN~1”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:51:14+00:00Added an answer on June 4, 2026 at 11:51 am

    Fixed it.

    I just suck @ win 32

    Removed marshals

    See solution:

    open System.IO
    open System.Runtime.InteropServices
    open System.Text
    
    [<DllImport("kernel32.dll",CharSet = CharSet.Auto, SetLastError=true)>]
    extern int GetShortPathName(
        string longpath, 
        StringBuilder shortpath, 
        int  item)
    
    let MakeShortName(longPath : string) =
        let sb =  StringBuilder()
        let currPath = longPath
        let item = 1024
    
       // let blah = ""
    //win32 assigns shortPath
        let blah32 = GetShortPathName(currPath, sb, item)
    
        sb.ToString()
    
    [<EntryPoint>]
    let main argv = 
    
    let path = @"C:\dev\shortName\shortName"
    let shorty = MakeShortName path
    printfn "%s" shorty 
    let x = System.Console.ReadKey()
    
    0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can not get to make this comparison in this simple code error ..
Any way I can get this working? I have a block of code: <p><a
How i can get full right name of generic type? For example: This code
While using this code, i can't get any results... Ext.define('Teste.view.Main', { extend: 'Ext.Container', initialize:
Even using the default test code on my app I can't get this working.
I ended up with this horrible code below, I can't get a better result
any idea how i can get the code below to produce this output? 1
How can I rewrite this code to coffeescript: $('.delete_action').click(function(event) { $.get('/delete_action?name=' + event.target.name +
In code like this, get '/posts.?:format?' do # ... end How can I get
Whenever I try to run this code: #Open file f = open(i.txt, r) line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.