Visual studio has null reference exception after .exe file is embedded into c# Project

54 views
Skip to first unread message

pallavi...@netelixir.com

unread,
Oct 30, 2018, 7:09:37 AM10/30/18
to AdWords API and Google Ads API Forum
I am using Google adwords Api for Excel addin in visual studio 2017. Unable to load account after button click event after creating .exe file for the project.

After creating .exe file for the project and installing the set up file.The setup file shows this unhandled exception.

The solution runs successfully before packaged as .exe file

Object reference not set to an instance of an object.




************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at
GoogleAPIIntraction.LXRAccount.btnaddaccount_Click(Object sender, EventArgs e)
   at
System.Windows.Forms.Control.OnClick(EventArgs e)
   at
System.Windows.Forms.Button.OnClick(EventArgs e)
   at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at
System.Windows.Forms.Control.WndProc(Message& m)
   at
System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at
System.Windows.Forms.Button.WndProc(Message& m)
   at
System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



CONFIDENTIALITY INFORMATION AND DISCLAIMER

This email message and its attachments may contain confidential, proprietary or legally privileged information and is intended solely for the use of the individual or entity to whom it is addressed. If you have erroneously received this message, please delete all copies of it immediately and notify the sender. If you are not the intended recipient of the email message you should not disseminate, distribute or copy this e-mail. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, incomplete or contain viruses and NetElixir accepts no liability for any damage caused by the limitations of the e-mail transmission. Thank you for your cooperation.

ExcelAddin.PNG

pallavi...@netelixir.com

unread,
Oct 31, 2018, 1:26:47 AM10/31/18
to AdWords API and Google Ads API Forum
Hi,

I am using Google Adwords Api for LXRPlugin[Excel AddIn] in visual studio 2017 c# project. 
The visual studio solution contains GoogleAPIIntraction as the main project.
 The solution runs successfully before .exe file is packaged.
After creating .exe file and installing the setup file I am getting the error.
I am not able to debug the .exe project step by step, but In log file following messages are shown in the build.

DownloadDllFiles() An exception occurred during a WebClient request.
DownloadXMLFiles() An exception occurred during a WebClient request.
Clicked on Add account button
selectd
package type:agency
 
Adword autherization login form


I am sharing the code for DownloadDllFiles and DownloadXMLFiles.

 private void DownloadDllFiles()
        {
            List<string> dllFiles = new List<string> { "Google.Ads.Common.dll", "Google.AdWords.dll" }; //"Google.Apis.Analytics.v3.dll", "Google.Apis.Auth.dll", "Google.Apis.Auth.PlatformServices.dll", "Google.Apis.Core.dll", "Google.Apis.dll", "Google.Apis.PlatformServices.dll" };
            string strAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            strAppDir = strAppDir.Remove(0, 6);
            System.Net.WebClient wc = new System.Net.WebClient();
            foreach (var dll in dllFiles)
            {
                string filePath = strAppDir + dll;
                try
                {
                    wc.DownloadFile(Globals.ThisAddIn.LXRXMLFilePath + dll, filePath);
                }
                catch (Exception ex) { LogWriter.Instance.CreateEntry("DownloadDllFiles() " + ex.Message); }
            }
        }

        private void DownloadXMLFiles()
        {
            List<string> xmlFiles = new List<string> { "ACCOUNT_PERFORMANCE_REPORT.xml", "ADGROUP_PERFORMANCE_REPORT.xml",
                "AD_EXTENSIONS_PERFORMANCE_REPORT.xml", "AD_PERFORMANCE_REPORT.xml", "AGE_RANGE_PERFORMANCE_REPORT.xml",
                "AUDIENCE_PERFORMANCE_REPORT.xml", "AUTOMATIC_PLACEMENTS_PERFORMANCE_REPORT.xml", "CALL_METRICS_CALL_DETAILS_REPORT.xml",
                "CAMPAIGN_NEGATIVE_KEYWORDS_PERFORMANCE_REPORT.xml", "CAMPAIGN_NEGATIVE_PLACEMENTS_PERFORMANCE_REPORT.xml",
                "CAMPAIGN_PERFORMANCE_REPORT.xml", "DISPLAY_KEYWORD_PERFORMANCE_REPORT.xml", "FINAL_URL_REPORT.xml",
                "GENDER_PERFORMANCE_REPORT.xml", "GEO_PERFORMANCE_REPORT.xml", "KEYWORDLESS_QUERY_REPORT.xml","ANALYTICS_QUERY_COLUMNS.xml",
                "KEYWORDS_PERFORMANCE_REPORT.xml", "SEARCH_QUERY_PERFORMANCE_REPORT.xml","PAID_ORGANIC_QUERY_REPORT.xml" };
            string strAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            strAppDir = strAppDir.Remove(0, 6);
            strAppDir = Path.Combine(strAppDir + "\\Xmls\\");
            System.Net.WebClient wc = new System.Net.WebClient();
            foreach (var xml in xmlFiles)
            {
                string filePath = strAppDir + xml;
                try
                {
                    wc.DownloadFile(Globals.ThisAddIn.LXRXMLFilePath + xml, filePath);
                }
                catch (Exception ex) { LogWriter.Instance.CreateEntry("DownloadXMLFiles() " + ex.Message); }
            }
        }

The following message is shown in log file when i select Google Analytics.

 Ribbon button1_Click Could not load file or assembly 'Google.Apis.Core, Version=1.33.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).


pallavi...@netelixir.com

unread,
Oct 31, 2018, 1:30:50 AM10/31/18
to AdWords API and Google Ads API Forum
Please solve my problem.

   Thanks in advance
Reply all
Reply to author
Forward
0 new messages