2015-04-13 1 views
0

Итак, я создал это веб-приложение, которое сделает звонок на сервер, чтобы получить информацию о ветвях, потоках, информации об изменении и т. Д. Я работаю над созданием api используя p4api.net.dll. Я загрузил и извлек его и выполнил инструкцию на странице perforce, чтобы подключиться к серверу.p4api.net.dll, используемый при создании webapi

**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, поэтому я добавил ее туда. Когда я запускаю мой апи я получаю следующее изображение:

response error after adding p4api.net to project

До сих пор все, что я пытался сделать, это установить соединение, используя следующий код:

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); 

Может кто-нибудь помочь мне для устранения этой проблемы, чтобы я мог хотя бы начать соединение?

ответ

0

Понял, что использовал неправильную версию p4api.net.dll. Я загрузил 64-битную версию, потому что это то, что моя версия O/S. Я попытался загрузить 32-разрядную версию, чтобы попробовать, и повторил мои шаги и бум, это сработало. Я положил файл p4bridge.dll в папку bin, где была установлена ​​p4api.net.dll. Надеюсь, это поможет любому, у кого была моя проблема.

Смежные вопросы