簡體   English   中英

用於創建WebAPI的p4api.net.dll

[英]p4api.net.dll used in creating a webapi

因此,我已經創建了此網絡應用程序,該應用程序將調用服務器以獲取有關分支,流,changset信息等的信息。我正在使用p4api.net.dll創建api。 我已經下載並解壓縮了它,並按照perforce頁面上的說明進行操作,以將其連接到服務器。

**Problem** 
Using C# and P4API.NET, how to I create a basic program to connect and disconnect from the server?
**Solution**    
The following code can be used as the foundation of a new P4API.NET program.  To use and compile this code, follow these steps:

1. Download the zipped P4API.NET  from the website(www.perforce.com) or the FTP site(ftp://ftp.perforce.com/perforce).  Extract it into a local directory.
2. Open Visual Studio.
3. From the menu, select New->Project...
4. From the Visual C# section, select Console Application
5. Fill in the Name and Location as appropriate.
6. Click the OK Button.
7. Once the new project loads, right-click on the References in the Solution Explorer and select the option  Add Reference... from the context menu.
8. Click on the Browse tab.  Navigate to the folder where you extracted the P4API.NET zipfile, and go into the lib folder.  Select p4api.net.dll (not p4bridge.dll) and click OK.
9. Cut and paste the code from below into the Program.cs file that was automatically created when you created the project, overwriting the default code.
10.Build the code by selecting Build -> Build Solution from the menu.
11.Open Windows Explorer.  Navigate to the folder where you extracted the P4API.NET zipfile, and copy the p4bridge.dll file to the bin/Debug directory of your solution.  You can set up the solution to copy it automatically, but it only needs to be done once.
12.Run the program with Debug -> Start Debugging 

If you want to run the program outside Visual Studio, always make sure that the p4api.net.dll and p4bridge.dll files are included with the binary.  The p4api.net.dll file contains the .NET assembly, while the p4bridge.dll contains the Perforce library.

現在,我跳過了第3-6步,其余步驟一直到第11步。在我的webapi項目中,我沒有bin / Debug文件夾。 我唯一的Debug文件夾在obj文件夾中,因此我在其中添加了它。 當我運行我的api時,我得到以下圖像:

將p4api.net添加到項目后的響應錯誤

到目前為止,我嘗試做的就是使用以下代碼建立連接:

string uri = "server:port";
string user = "username";
string ws_client = "ws_name";

Perforce.P4.Server server = new Perforce.P4.Server(new ServerAddress(uri));
Repository rep = new Repository(server);
Connection con = rep.Connection;

con.UserName = user;
con.Client = new Client();
con.Client.Name = ws_client;

con.Connect(null);

誰能幫我解決這個問題,以便至少可以開始建立連接?

弄清楚我使用的是錯誤版本的p4api.net.dll。 我下載了64位版本,因為這是我的操作系統的版本。 我嘗試下載32位版本只是為了嘗試一下,然后重復了我的步驟和努力,一切正常。 我最終將p4bridge.dll文件放到安裝了p4api.net.dll的bin文件夾中。 希望這對遇到我問題的人有所幫助。

暫無
暫無

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

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