簡體   English   中英

將參數發送到 exe 文件(可執行文件)c# 或在 memory 中創建可執行文件 c#

[英]Send Parameters to an exe file (Executable) c# or create executable file c# in memory

我正在為我的小學生制作 web 和 C# 中的桌面應用程序,以便他們可以登錄 web 並為他們的課程下載程序。 web 和應用程序都可以在 Azure 存儲中找到。

我創建的應用程序非常小,因為它只負責下載和執行必要的 dll,其中 forms 將包含課程和考試。

我遇到的問題是我希望將登錄數據(用戶名和/或密碼)作為參數發送到應用程序中,這樣他們就不必在桌面應用程序中再次登錄。

我試圖讓應用程序以某種方式讀取 cookies,但放棄了這個想法,因為它在很大程度上取決於瀏覽器。

The other and more understandable idea is to create a web service that generates the executable file (exe) in memory (it has to be in memory because I don't have write and read access to disk, I'm using Azure Storage and Azure服務),它使用文件流或類似的東西下載。

我找到了這個例子,但這一定需要一個目錄來生成exe文件,是否可以在memory中生成exe文件?

或者是否可以將參數傳遞給已編譯的 exe 文件。

Public Sub generateFile ()
    Dim codeProvider As New VBCodeProvider ()
    Dim icc As ICodeCompiler = codeProvider.CreateCompiler
    Dim Output As String = "C: \ Program Files \ MyApp.exe"


    Dim parameters As New CompilerParameters ()
    Dim results As CompilerResults

    'Make sure we generate an EXE, not a DLL
    parameters.GenerateExecutable = True
    parameters.OutputAssembly = Output
    parameters.CompilerOptions = ("/ target: winexe" & "" & "/ win32icon:" & "" "") & "C: \ Program Files \ MyIcons \ Icon.ico" & "" ""

    results = icc.CompileAssemblyFromSource (parameters, txtCode.Text)

    If results.Errors.Count> 0 Then
        'There were compiler errors
        Dim CompErr As CompilerError
        For Each CompErr In results.Errors
            MessageBox.Show (
                "Line number" & CompErr.Line &
                ", Error Number:" & CompErr.ErrorNumber &
                ", '" & CompErr.ErrorText & ";" &
                Environment.NewLine & Environment.NewLine)
        Next
    Else

        'Successfull Compile
        MessageBox.Show ("Your file is successfully generated!", "Success")
    End if
End Sub

The desktop application is small, it is only responsible for downloading and executing the last dll contained in a directory in azure storage, the classes and forms will be in these dll.

非常感謝您的閱讀。 我為我的英語道歉,我來自阿根廷

我遇到的問題是我希望將登錄數據(用戶名和/或密碼)作為參數發送到應用程序中,這樣他們就不必在桌面應用程序中再次登錄。

這不是一件簡單的事情。 以下是我建議的步驟以及用戶體驗。

  1. 用戶登錄 Web 站點
  2. 用戶下載安裝程序
  3. 用戶啟動安裝程序

    一個。 在安裝期間,應用程序注冊一個自定義 URI 方案將應用程序注冊到 URI 方案

現在無論是在安裝之后還是用戶正在執行應用程序,以下內容都是相同的。

  1. 用戶啟動應用程序(或安裝程序)
  2. 應用程序啟動瀏覽器以登錄
  3. 用戶登錄和瀏覽器使用憑據(不是用戶名/密碼)重定向到您的自定義 URI 方案,因此您的應用程序現在可以在下載任何內容時進行身份驗證。

這是很常見的。 GotoMeeting、Slack、Discord 和其他各種應用程序都做同樣的事情。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM