|
nzmike wrote:
The type or namespace 'PayPalAPIInterfaceService' could not be found - are you missing a using directive or an assembly reference?).
If you have the using directive, you must be missing the assembly reference. Have you linked your project to their assembly ? If it's a webservice, perhaps you need to import their service into the project ( get a web reference to it ) ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian but could you elaborate a little more? I've already added the web reference to the project (Project -> Add Web Reference) and it seems fine.... do I have do something else as well?
Mike
|
|
|
|
|
Does the class that was generated have the namespace you're trying to use ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You mean the reference.cs that's created when I add the web servce reference or the name of the entire class I'm trying to create?
If it's the former then I think so... my solution and project are both called PayPalAPI and in it I have created a new class called APIWrapper.cs which, when compiled, is to be used to call PayPal services from other .Net apps. The namespace of this class is PayPalAPI. The namespace of the reference.cs that was generated after adding the WS is PayPalAPI.PayPalSvc. (I had to rename the WS from com.paypal.www to 'PayPalSvc' when I added it.)
Does that help or have I confused you?
Thanks for bearing with me - I've used web services before so can't understand what's happening here!
Mike
|
|
|
|
|
'PayPalAPIInterfaceService' is what you can't find - where did it come from, and does it appear in your code ? Could it be a reference to something that was renamed when you renamed the WS ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
'"PayPalAPIInterfaceService" description' is what the WSDL screen shows when you type the reference to the PayPal web services (http://www.paypal.com/wsdl/PayPalSvc.wsdl) and hit "go". It says "1 service found - PayPalSvc" and the name is com.paypal.www. I rename that to PayPalSvc and click "Add Reference". The code below in my wrapper class then tries to access PayPalAPIInterfaceService. (I've marked the error lines with "//GETS ERROR HERE".... that's where the compiler says it can't find PayPalAPIInterfaceService.)
If you want I could zip up the project and email it to you or make it downlaodable from my server... it might be easier to see waht's going on - let me know if that would help.
Thanks again,
Mike
------------ APIWrapper.cs --------------------
using System;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using PayPalAPI.PayPalSvc;
using PayPalAPI;
using System.Data;
using System.Collections;
using System.Security;
namespace PayPalAPI
{
///
/// Summary description for APIWrapper.
///
public class APIWrapper
{
string _APIUserName="";
string _APIPassword="";
string _CertLocation="";
string _APIUrl="";
public string APIUserName
{
get{return _APIUserName;}
}
public string APIPassword
{
get{return _APIPassword;}
}
public string CertLocation
{
get{return _CertLocation;}
}
public string APIUrl
{
get{return _APIUrl;}
}
PayPalAPIInterfaceService service; //GETS ERROR HERE
public APIWrapper(String APIUserName, string APIPassword, string CertLocation, string APIUrl)
{
_APIUserName=APIUserName;
_APIPassword=APIPassword;
_CertLocation=CertLocation;
_APIUrl=APIUrl;
// Add the CertificatePolicy so we can post to an untrusted site
ServicePointManager.CertificatePolicy = new MyCertificateValidation( );
service = new PayPalAPIInterfaceService( ); //GETS ERROR HERE
service.Url = _APIUrl;
// Add the X509 Cert to the service for authentication
X509Certificate certificate = X509Certificate.CreateFromCertFile(_CertLocation);
service.ClientCertificates.Add(certificate);
SetHeaderCredentials(service);
}
void SetHeaderCredentials(PayPalAPIInterfaceService service)
{
CustomSecurityHeaderType securityHeader = new CustomSecurityHeaderType( );
UserIdPasswordType userIdPassword = new UserIdPasswordType( );
userIdPassword.Username = _APIUserName;
userIdPassword.Password = _APIPassword;
//userIdPassword.Subject = subject;
securityHeader.Credentials = userIdPassword;
securityHeader.MustUnderstand = true;
service.RequesterCredentials = securityHeader;
}
string GetAmountValue(BasicAmountType amount)
{
string sOut="";
try
{
sOut="$"+amount.Value.ToString( );
amount.currencyID = CurrencyCodeType.USD;
}
catch
{
sOut="--";
}
return sOut;
}
}
class MyCertificateValidation : ICertificatePolicy
{
// Default policy for certificate validation.
public static bool DefaultValidate = false;
public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest request, int problem)
{
//implement your custom code here
return true;
}
}
}
------------ APIWrapper.cs --------------------
|
|
|
|
|
Actually, if you could give me the URL to generate the web reference, that may be just as good.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
http://www.paypal.com/wsdl/PayPalSvc.wsdl
I'm not sure what happens if you try and add it without a local certificate from PayPal (to use it's API)... I have the cert for our merchant account installed in the PErsonal and Other People certificate stores.
Mike
|
|
|
|
|
I was able to add the web service, but it did not wrap "paypalsvc" in another namespace, I was able to create and manipulate objects using PayPalSvc.Classname varName = new PayPalSvc.Classname(). I'd search across the project for 'PayPalAPIInterfaceService', and see where it's expecting to find it. It does not appear within the webservice, the problem is elsewhere.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok, well thanks for trying.
I'm now starting from scratch with a very simple forms app that uses the service (the code I had for the APIWrapper class was from the "PayPal Hacks" book) so will see what luck I have with that.
I also now have a direct technical support contact at PayPal so hopefully if the problem persists he will look at it.
Many thanks for your help.... it was much appreciated.
Mike
|
|
|
|
|
I am attempting to send a message using CDO in a ASP.NET/C# Application:
I receive the following Error when trying to update the fields:
////////////////////////////////////////////
ERROR
////////////////////////////////////////////
Fields update failed. For further information, examine the Status property of individual field objects.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Fields update failed. For further information, examine the Status property of individual field objects.
////////////////////////////////////////////
The code looks like the following:
////////////////////////////////////////////
//// CLASS VARIABLES
static private String _currStoreName = "My";
static StoreClass _oCurrStore;
const string CDO_MailServer = "mail.dovetailinternet.com";
const string CDO_ContentDisposition = "attachment;filename=smime.p7m";
const int CDO_SmtpPort = 25;
const int CDO_SendUsingType = 2;
private Certificates oCerts;
private Certificate oCert;
private EnvelopedData oEnvData;
////METHODS
private void CDOMail()
{
CDO.Configuration mailerConfig = new CDO.ConfigurationClass();
CDO.IMessage firstMsg = new CDO.MessageClass();
CDO.IMessage secondMsg = new CDO.MessageClass();
mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = CDO_SendUsingType;
mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = CDO_MailServer;
mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = CDO_SmtpPort;
mailerConfig.Fields.Update();
firstMsg.Sender = "from@internet.com";
firstMsg.To = "to@internet.com";
firstMsg.Subject = "First Message Subject";
firstMsg.TextBody = "Message One Body";
secondMsg.DataSource.OpenObject(firstMsg, "IMessage");
CDO.IBodyPart oBodyPart = secondMsg.BodyPart;
oBodyPart.ContentMediaType = "application/pkcs7-mime;smime-type=enveloped-data;name=smime.p7m;";
oBodyPart.ContentTransferEncoding = "base64";
//*** Update That Fails
oBodyPart.Fields["urn:schemas:mailheader:content-disposition"].Value = CDO_ContentDisposition;
oBodyPart.Fields.Update();
//***
secondMsg = EnvelopeMessage(secondMsg);
secondMsg.Configuration = mailerConfig;
secondMsg.Send();
}
//// ENVELOPMESSAGE
private CDO.IMessage EnvelopeMessage(CDO.IMessage msg)
{
CDO.Message oSecMsg = new CDO.MessageClass();
oSecMsg.DataSource.OpenObject(msg, "IMessage");
_oCurrStore = new StoreClass();
_oCurrStore.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, _currStoreName,CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY | CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);
oCerts = (Certificates)_oCurrStore.Certificates;
foreach(Certificate cert in oCerts)
{
oCert = cert;
}
CAPICOM.EnvelopedData oEnvData = new CAPICOM.EnvelopedDataClass();
oEnvData.Recipients.Add(oCert);
ADODB.Stream tmpStream = oSecMsg.BodyPart.GetStream();
string strContent = tmpStream.ReadText(tmpStream.Size);
oEnvData.Content = strContent;
string strData = oEnvData.Encrypt(CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);
ADODB.Stream oStream = oSecMsg.BodyPart.GetDecodedContentStream();
oStream.Type = ADODB.StreamTypeEnum.adTypeBinary;
byte[] byteData = Convert.FromBase64String(strData);
oStream.Write(byteData);
oStream.Flush();
oStream.Close();
return oSecMsg;
}
Any help would be greatly appreciated, i've been trying to resolve the issue for hours on end, and know that eliminating this error will likely yield the desired effect.
I have been unable to find any good examples of sending CDO.Mail with .NET except the one here:
http://support.microsoft.com/Default.aspx?kbid=280391
I Followed the Instructions and am now faced with this problem. Please Help me!
|
|
|
|
|
I want to get a date with the "dd/MM/yyyy" format in C#.net, but when I write the code like
date_txt.Text = System.DateTime.Today.Date.ToShortDateString;
In the textbox it shows 2005-08-03, this format. And it can't be written into the access source database.
Does anybody know how to get "dd/MM/yyyy" this kind of date format and write it into access source database???
By the way, if I want to display some record between two dates, any ideas???
Many Thanks
Asura
|
|
|
|
|
The display format is independant of the way the date gets stored in Access. The default display format depends on your locale settings. To write dates to access (or any database, for that matter) the best approach is to use parameterised queries, and pass the date as a parameter of oledbtype.Date, which maps directly to System.DateTime (access uses the double seconds since 1899 as its storage type).
To display the date, you could specify the format:
<code>
date_txt.Text = System.DateTime.Today.ToString("dd/MM/yyyy")</code>
To display a date between two dates, use a parameterized query:
<code>string myQuery = "Select * from MyTable where MyDateField Between ? and ?"
OledbCommand myCommand = new OleDbCommand(myQuery, mYDbConnection);
myCommand.Parameters.Add("@StartDate",startingDateTime);
myCommand.Parameters.Add("@EndDate",endingDateTime);
OleDbDataReader dr = myCommand.ExecuteReader;
while(dr.Read())
{
...
}</code>
<small><b>Absolute faith corrupts as absolutely as absolute power<i>
Eric Hoffer</i></b></small>
<small><b>All that is necessary for the triumph of evil is that good men do nothing.
<i>Edmund Burke</i></b></small>
|
|
|
|
|
Thanks for your code. Could you tell me how to declare the variable as OleDbType.Date please, because I tried that, and it says that OleDbType.Date is a field but not a class. Therefore I still don't know how to pass the date as a parameter. Also, if I want to change the local settings, where can I find it please?
Thanks in advance
Asura
|
|
|
|
|
Are you sure that you can't use a date with that format with Access? That date format follows the ISO 8601 standard, and it is unambigous. I have never had any problems with that date format.
The dd/MM/yyyy format on the other hand is ambigous. The date 03/08/2005 can be interpreted either as 2005-08-03 or 2005-03-08.
I am not convinced that it's the date format that is the problem. How do you enter the date into the database?
---
b { font-weight: normal; }
|
|
|
|
|
I used a number of ways of writing the date information back into the database. For example,
DataTable table = ds.Table["Customer"];
table["date"] = System.DateTime.Today.Date.ToString("dd/MM/yyyy");
||
table["date"] = Convert.ToDateTime(System.DateTime.Today.Date.ToString("dd/MM/yyyy"));
||
table["date"] = System.DateTime.Parse(date_str);
I try the above ways, but none of them works.
Could you tell me how you enter the date into the database please??
Asura
|
|
|
|
|
Each of the methods you tried involved converting a string to a date. That means that you rely on the culture specified by default to correctly interpret the date. Obviously the default culture is not the one you wish to use, so it doesn't.
Provide a DateTimeFormat for the culture you wish to use. I would use a swedish CultureInfo (LCID 1053) to parse a date in swedish format:
string dateString = "2005-08-05";<br />
table["date"] = System.DateTime.Parse(dateString, new CultureInfo(1053).DateTimeFormat);
---
b { font-weight: normal; }
|
|
|
|
|
Does somebody know if there's a way to retrieve information about windows accounts registered on a specific computer? (usernames would be enough)
Tks a lot
Lucio
|
|
|
|
|
|
you can use Network Management Functions to
get info like you want create group ,get group user,etc
Network Management Functions[^]
i dont know if .net have equivalent functionality
|
|
|
|
|
|
I was just wondering what you guys are using to protect the applications written in any language under the .Net Framework. Do you prefer the exe packers and crypters, or some other schemes?
Which scheme is the best to implement, and presents a good ratio between a price/time to implement/protection it offers?
Thanks.
|
|
|
|
|
Hi Damir,
Its realy difficult to protect a .NET Application, because the application is only IL-Code (with a win32 loader) and you can recreate the code of it really good.
Try Lutz Roeder's Reflector[^], for instance with the System.dll (Framework Namespace System).
One solution is to use a obfuscator. The obfuscator renames all variables and methodes in useless terms, like a12423.
But a have no tip for a special product.
A communication version (free for students and freeware authors) of the dotfuscator is part of visual studio 2003. See: http://preemptive.com/products/dotfuscator/Editions.html[^]
A free alternative is the Aspose Obfuscator/[^].
An other idee is to pack all used dll's in one stream and embedded this stream as embedded resource in the application. Unpack this stream at runtime and load the dlls from this unpacked memory. Its simple possible to crypt the embedded stream.
A example implementation is descript in the magazin Dr. Dobb's Journal March 2005.
Reducing the Size of .NET Applications[^]
Hope, it's help a bit
Niedzi
|
|
|
|
|
|
I have a form with FormBorderStyle set to Sizable , and no minimize or maximize buttons, and no ShowInTaskbar . It displays the default Windows Forms icon in the title bar, even if I set the Icon property to null in the constructor.
Is there a way to have a sizable dialog without that little icon in the caption? How?
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|