<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Compile error when building a C# application in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378389#M24616</link>
    <description>&lt;P&gt;I was working my way thru&amp;nbsp;the paper 016-2007&amp;nbsp;to understand how to&amp;nbsp;build&amp;nbsp;OLE automation C# applications&amp;nbsp;over&amp;nbsp;my SAS Enterprise guide&amp;nbsp;projects. I use Visual Studio C# Enterprise 2015 and SAS Enterprise Guide 7.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried compiling&amp;nbsp;the following piece of C# code&lt;/P&gt;&lt;PRE&gt;using System;
namespace test
{
    class test
    {
        static void Main(string[] args)
        {
            SAS.EG.Scripting.Application EGApp = new SAS.EG.Scripting.Application();

            SAS.EG.Scripting.Project EGProject = EGApp.Open("E:\\SASDocuments\\EGProjectTest.egp","");

            
            //Close the project
            EGProject.Close();
            //Exit the application
            EGApp.Quit();
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and got the following error.&lt;/P&gt;&lt;PRE&gt;Error	CS0266	Cannot implicitly convert type 'SAS.EG.Scripting.ISASEGProject' to 'SAS.EG.Scripting.Project'. An explicit conversion exists (are you missing a cast?)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If Scripting.ISASEGProject is an interface to Scripting.Project why does it complain? Please help.&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jul 2017 07:01:59 GMT</pubDate>
    <dc:creator>andrnev</dc:creator>
    <dc:date>2017-07-22T07:01:59Z</dc:date>
    <item>
      <title>Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378389#M24616</link>
      <description>&lt;P&gt;I was working my way thru&amp;nbsp;the paper 016-2007&amp;nbsp;to understand how to&amp;nbsp;build&amp;nbsp;OLE automation C# applications&amp;nbsp;over&amp;nbsp;my SAS Enterprise guide&amp;nbsp;projects. I use Visual Studio C# Enterprise 2015 and SAS Enterprise Guide 7.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried compiling&amp;nbsp;the following piece of C# code&lt;/P&gt;&lt;PRE&gt;using System;
namespace test
{
    class test
    {
        static void Main(string[] args)
        {
            SAS.EG.Scripting.Application EGApp = new SAS.EG.Scripting.Application();

            SAS.EG.Scripting.Project EGProject = EGApp.Open("E:\\SASDocuments\\EGProjectTest.egp","");

            
            //Close the project
            EGProject.Close();
            //Exit the application
            EGApp.Quit();
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and got the following error.&lt;/P&gt;&lt;PRE&gt;Error	CS0266	Cannot implicitly convert type 'SAS.EG.Scripting.ISASEGProject' to 'SAS.EG.Scripting.Project'. An explicit conversion exists (are you missing a cast?)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If Scripting.ISASEGProject is an interface to Scripting.Project why does it complain? Please help.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 07:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378389#M24616</guid>
      <dc:creator>andrnev</dc:creator>
      <dc:date>2017-07-22T07:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378448#M24618</link>
      <description>&lt;P&gt;Check this more modern blog post and paper on &lt;A href="http://blogs.sas.com/content/sasdummy/2012/04/17/doing-more-with-sas-enterprise-guide-automation/" target="_self"&gt;the topic of SAS Enterprise Guide automation&lt;/A&gt;. &amp;nbsp;It points to a more complete .NET example that might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a &lt;A href="http://support.sas.com/documentation/onlinedoc/guide/examples/SASGF2012/Hemedinger_298-2012.pdf" target="_self"&gt;direct link to the paper&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 17:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378448#M24618</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-07-22T17:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378595#M24630</link>
      <description>&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;Many thanks. I see that the AssembylResolver code points to the 4.3 installation of SAS Enterprise guide. Compilation succeeds but execution fails citing a System.IO.FileNotFoundException. Possibly this is because I have SAS Enterprise guide 7.1 installed instead of 4.3. I then looked into the registry for the equivalent 7.1 installation&amp;nbsp;and surprisingly I dont find any installation of 7.1 as per the path below, root being HKEY_LOCAL_MACHINE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="Consolas" size="2"&gt;"SOFTWARE\SAS Institute Inc.\Enterprise Guide\4.3"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There must be some issue with my&amp;nbsp;SAS Enterprise Guide 7.1 (32-bit) installation right?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 07:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378595#M24630</guid>
      <dc:creator>andrnev</dc:creator>
      <dc:date>2017-07-24T07:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378641#M24638</link>
      <description>&lt;P&gt;Make sure that you're looking in the proper registry location. &amp;nbsp;64-bit Windows has two registries: a 32-bit version and a 64-bit version. &amp;nbsp;If you have EG 32-bit, then you want to make sure that you are building your .NET application as a 32-bit (x86 architecture) application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A 32-bit EG key will be in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HKEY_LOCAL_MACHINE\SOFTWARE\&lt;STRONG&gt;WOW6432Node&lt;/STRONG&gt;\SAS Institute Inc.\Enterprise Guide\7.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 11:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378641#M24638</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-07-24T11:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378661#M24639</link>
      <description>&lt;P&gt;Ok. I do see the installation in the key you mentioned. I now modifed the SEG43AssemblyResolver.cs file to the following. I still get an System.IO.FileNotFoundException exception though. I have&amp;nbsp;also posted the exception details below the code (it seems to refer to some file FileName=C:\Program Files (x86)\SASHome\EnterpriseGuide\7.1\EGPSearch43.resources.dll which does not exist&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using System;
using System.IO;
using System.Reflection;
using Microsoft.Win32;

namespace SAS.EG.Automation
{
    /// &amp;lt;summary&amp;gt;
    /// Class to help you use SAS Enterprise Guide classes from their installed location
    /// &amp;lt;/summary&amp;gt;
    public class SEG43AssemblyResolver
    {
        #region internal members
        // these are the default install paths for our 4.3/9.2 products
        //internal static string PathToEGuideInstall = @"C:\Program Files\SAS\EnterpriseGuide\4.3";
        internal static string PathToEGuideInstall = @"C:\Program Files (x86)\SASHome\EnterpriseGuide\7.1";
        #endregion

        /// &amp;lt;summary&amp;gt;
        /// Install the AssemblyResolver event listener and discover locations of installed assemblies
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;exception cref="System.IO.FileNotFoundException"&amp;gt;Thrown when unable to locate the SAS Enterprise Guide 4.3 installed location.&amp;lt;/exception&amp;gt;
        public static void Install()
        {
            // initialize EG path

            RegistryKey regKey = null;
            try
            {
                // determine EG 4.3 location using InstallShield key
                //using (regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\SAS Institute Inc.\Enterprise Guide\4.3", false))
                using (regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\SAS Institute Inc.\Enterprise Guide\7.1", false))
                {
                    if ((regKey != null) &amp;amp;&amp;amp; (regKey.GetValue("InstallLocation") != null))
                    {
                        string path = regKey.GetValue("InstallLocation") as string;
                        if (path.Length &amp;gt; 0)
                            PathToEGuideInstall = path;
                    }
                    else
                        throw new System.IO.FileNotFoundException("Cannot locate SAS Enterprise Guide 7.1.  Is SAS Enterprise Guide 7.1 installed?");
                }
            }
            catch
            {
                throw new System.IO.FileNotFoundException("Cannot locate SAS Enterprise Guide 7.1.  Is SAS Enterprise Guide 7.1 installed?");
            }

            // install Assembly Resolver event
            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.AssemblyResolve += new ResolveEventHandler(currentDomain_AssemblyResolve);
        }

        /// &amp;lt;summary&amp;gt;
        /// Resolve assemblies not found in the current directory
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="sender"&amp;gt;Sender of event&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="args"&amp;gt;contains a Name property with the assembly name needed&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Loaded assembly, loaded by this routine&amp;lt;/returns&amp;gt;
        private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            string resolvepath;
            // all files that are "early bound" should be in the Enterprise Guide directory
            resolvepath = PathToEGuideInstall;

            string[] name = args.Name.Split(',');
            string path = System.IO.Path.Combine(resolvepath, name[0] + ".dll");
            try
            {
                Assembly foundAssembly = Assembly.LoadFile(path);
                return foundAssembly;
            }
            catch (System.IO.FileNotFoundException ex)
            {
                throw new System.IO.FileNotFoundException("Could not load assembly from expected location", path, ex);
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also posting the exception message behind the System.IO.FileNotFoundException&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;System.IO.FileNotFoundException was unhandled
  FileName=EGPSearch43.resources, Version=4.3.0.0, Culture=en-US, PublicKeyToken=null
  FusionLog=""
  HResult=-2147024894
  Message=Could not load file or assembly 'EGPSearch43.resources, Version=4.3.0.0, Culture=en-US, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
  Source=mscorlib
  StackTrace:
       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp;amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark&amp;amp; stackMark)
       at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark&amp;amp; stackMark)
       at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark&amp;amp; stackMark)
       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark&amp;amp; stackMark)
       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
       at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
       at System.Resources.ResourceManager.GetObject(String name)
       at EGPSearch.MainSearchWindow.InitializeComponent() in E:\SASDocuments\EGPSearch_Sample\EGPSearch_src\Core\MainSearchWindow.Designer.cs:line 278
       at EGPSearch.MainSearchWindow..ctor(String version) in E:\SASDocuments\EGPSearch_Sample\EGPSearch_src\Core\MainSearchWindow.cs:line 38
       at EGPSearch.Program.Main() in E:\SASDocuments\EGPSearch_Sample\EGPSearch_src\43\Program.cs:line 48
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       FileName=C:\Program Files (x86)\SASHome\EnterpriseGuide\7.1\EGPSearch43.resources.dll
       HResult=-2147024894
       Message=Could not load assembly from expected location
       Source=EGPSearch43
       StackTrace:
            at SAS.EG.Automation.SEG43AssemblyResolver.currentDomain_AssemblyResolve(Object sender, ResolveEventArgs args) in E:\SASDocuments\EGPSearch_Sample\EGPSearch_src\43\SEG43AssemblyResolver.cs:line 75
            at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
       InnerException: 
            HResult=-2147024894
            Message=The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
            Source=mscorlib
            StackTrace:
                 at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
                 at System.Reflection.Assembly.LoadFile(String path)
                 at SAS.EG.Automation.SEG43AssemblyResolver.currentDomain_AssemblyResolve(Object sender, ResolveEventArgs args) in E:\SASDocuments\EGPSearch_Sample\EGPSearch_src\43\SEG43AssemblyResolver.cs:line 70
            InnerException: &lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 12:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378661#M24639</guid>
      <dc:creator>andrnev</dc:creator>
      <dc:date>2017-07-24T12:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378665#M24640</link>
      <description>&lt;P&gt;"EGPSearch" is the root name of the example searcher project that I shared in that SAS Global Forum paper, and so its resources should be part of the EXE that you're building -- unless you've altered the name. &amp;nbsp;Something seems to be out of sync. &amp;nbsp;If you're adapting my example by modifying it in place, maybe a better approach is to create a new project from scratch and add in just the references that you need.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 12:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378665#M24640</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-07-24T12:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Compile error when building a C# application</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378906#M24662</link>
      <description>&lt;P&gt;Chris, thanks. I get it to compile and run without it crashing using only the AssemblyResolver installation code.&amp;nbsp;I would have&amp;nbsp;to reproduce the&amp;nbsp;UI code to check whether the querying part&amp;nbsp;works. Will close this&amp;nbsp;discussion for now with many thanks for your support&amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 08:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Compile-error-when-building-a-C-application/m-p/378906#M24662</guid>
      <dc:creator>andrnev</dc:creator>
      <dc:date>2017-07-25T08:51:51Z</dc:date>
    </item>
  </channel>
</rss>

