Exception has been thrown by the target of an invocation

989 views
Skip to first unread message

VK

unread,
Feb 14, 2012, 12:47:09 PM2/14/12
to AdWords API Forum
Hi,

I am hoping you could point me in the right direction
I am trying to call the Adwords API within a SSIS Script task(VB.NET
Visual Studio 2005),the user is initialized as below


Dim UserDict As New Dictionary(Of String, String)
UserDict.Add("UserAgent", "XXX")
UserDict.Add("ClientEmail", "XXX")
UserDict.Add("DeveloperToken", "XXX")
UserDict.Add("AuthorizationMethod", "ClientLogin")
UserDict.Add("Email", "XX")
UserDict.Add("Password", "XX")
UserDict.Add("AdWordsApi.Server", "https://adwords-
sandbox.google.com")

user = New AdWordsUser(UserDict)

I get an error on the first line after the user is initialized

Dim infoService As InfoService =
CType(user.GetService(AdWordsService.v201109.InfoService),
Google.Api.Ads.AdWords.v201109.InfoService)


at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,
Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly,
Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at
Google.Api.Ads.AdWords.Lib.AdWordsServiceFactory.CreateService(ServiceSignature
signature, AdsUser user, Uri serverUrl)
at Google.Api.Ads.Common.Lib.AdsUser.GetService(ServiceSignature
serviceSignature, Uri serverUrl)
at Google.Api.Ads.Common.Lib.AdsUser.GetService(ServiceSignature
serviceSignature, String serverUrl)
at Google.Api.Ads.Common.Lib.AdsUser.GetService(ServiceSignature
serviceSignature)
at ScriptTask_ccb838f94ed54707841fdafbf304dd05.ScriptMain.Main()

Thank you!!
Vaibhavi

Anash P. Oommen

unread,
Feb 15, 2012, 12:39:00 AM2/15/12
to adwor...@googlegroups.com
Hi Vaibhavi,

Try switching to the latest version of the client library. Also, make sure that your App.config matches the one that comes with the library - especially this line: http://code.google.com/p/google-api-adwords-dotnet/source/browse/trunk/src/AdWords/App.config#73

Let me know if this solves your problems. Basically, it is some object throwing an exception in its constructor, and a bad App.config is the usual reason.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

VK

unread,
Feb 15, 2012, 7:50:05 PM2/15/12
to AdWords API Forum
Thanks Anash for your suggestion. I did switch to the latest version
of the client library but still get the same error on the very first
line after the user is initialized. It displays the config values like
ClientCustomer ID ,Email,Password etc correctly from the App.config

I think its a problem with the method GetService on the AdWordsUser
object. Is there anything else that i can try?

Dim infoService As InfoService =
CType(user.GetService(AdWordsService.v201109.InfoService),
Google.Api.Ads.AdWords.v201109.InfoService)

Thanks
Vaibhavi



On Feb 14, 9:39 pm, "Anash P. Oommen" <anash.p.oommen
+fo...@google.com> wrote:
> Hi Vaibhavi,
>
> Try switching to the latest version of the client library. Also, make sure
> that your App.config matches the one that comes with the library -
> especially this line:http://code.google.com/p/google-api-adwords-dotnet/source/browse/trun...

Anash P. Oommen

unread,
Feb 16, 2012, 3:06:34 AM2/16/12
to adwor...@googlegroups.com
HI Vaibhavi,

Could you mail me a minimal VS project to anash.p.oo...@google.com? I could take a look and send you back the fixed project. You could clear out the credentials in your App.config. Also, make sure you change the file extension to something else (e.g. .zips). Gmail doesn't allow zip files with binaries in it as an attachment.

VK

unread,
Feb 16, 2012, 3:11:25 PM2/16/12
to AdWords API Forum
Hi Anash,

Its actually an integration services project for SQL 2005 so I did a
quick VS 2008 console solution targetting to .NET 2.0 on the server
and it did throw the same error with more details. I have emailed you
this console solution

For the integration services project to work, had to install the
assemblies to GAC,so on purpose i have added the reference from GAC
for Google.Ads.Common.dll and Google.Adwords.dll on the VS2008
solution


InnerException: System.Configuration.ConfigurationErrorsException
BareMessage="The value of the property 'type' cannot be parsed.
The error is: Could not load file or assembly 'Google.Ads.Common' or
one of its dependencies. The system cannot find the file specified."
Filename="D:\Adwords\TestAdwordsAPI\TestAdwordsAPI\bin\Debug
\TestAdwordsAPI.vshost.exe.config"
Line=73
Message="The value of the property 'type' cannot be parsed. The
error is: Could not load file or assembly 'Google.Ads.Common' or one
of its dependencies. The system cannot find the file specified. (D:
\Adwords\TestAdwordsAPI\TestAdwordsAPI\bin\Debug
\TestAdwordsAPI.vshost.exe.config line 73)"
Source="System.Configuration"
StackTrace:
at
System.Configuration.PrivilegedConfigurationManager.GetSection(String
sectionName) at
System.Web.Services.Configuration.WebServicesSection.get_Current()
at System.Web.Services.Protocols.SoapClientType..ctor(Type type) at
System.Web.Services.Protocols.SoapHttpClientProtocol..ctor() at
Google.Api.Ads.Common.Lib.AdsSoapClient..ctor() at
Google.Api.Ads.AdWords.v201109.CampaignService..ctor()
InnerException:

Thanks much,
Vaibhavi

On Feb 16, 12:06 am, "Anash P. Oommen" <anash.p.oommen
+fo...@google.com> wrote:
> HI Vaibhavi,
>
> Could you mail me a minimal VS project to anash.p.oommen+fo...@google.com?

Anash P. Oommen

unread,
Feb 21, 2012, 5:39:58 AM2/21/12
to adwor...@googlegroups.com
Hi Vaibhavi,

As I mentioned in my email, the current assemblies in the public distribution aren't signed (patch coming up next release). Also, when you refer the assemblies from GAC, the runtime loads the assemblies only from GAC. So for any type resolution, you should have the fully qualified name in your App.config. Something like this:

<add type="Google.Api.Ads.Common.Lib.SoapListenerExtension, Google.Ads.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc" priority="1" group="0"/>

VK

unread,
Oct 11, 2012, 1:42:47 PM10/11/12
to adwor...@googlegroups.com
Hi Anash,

Where can I get the latest signed version of the dot net client libraries?

Thank you!
Vaibhavi
Reply all
Reply to author
Forward
0 new messages