<?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 Re: Failure in running c# code SAS EG 7.1 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313141#M21130</link>
    <description>&lt;P&gt;You can use an Assembly Resolver class/event to load the DLLs from the EG install as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a class like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    /// &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 SEG71AssemblyResolver
    {
        #region internal members
        internal static string PathToEGuideInstall = @"C:\Program Files\SAS\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;
        public static void Install(string path)
        {
            PathToEGuideInstall = path;

            // 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[] name = args.Name.Split(',');
            string path = System.IO.Path.Combine(PathToEGuideInstall, name[0] + ".dll");
            try
            {
                Assembly foundAssembly = Assembly.LoadFile(path);
                return foundAssembly;
            }
            catch (System.IO.FileNotFoundException)
            {
                return null;
            }
        }
    }
&lt;/PRE&gt;
&lt;P&gt;Then "install" this handler in the Main() function for your app:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  SAS.EG.Automation.SEG71AssemblyResolver.Install(EGinstall);&lt;/PRE&gt;
&lt;P&gt;Passing in the path where EG is installed on your system. &amp;nbsp;This class *should* direct the .NET runtime to load any assembly it needs from the installed app folder.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 16:09:00 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-11-21T16:09:00Z</dc:date>
    <item>
      <title>Failure in running c# code SAS EG 7.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/312654#M21112</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i would like to automate the creation of a SAS 7.1 project and decided to use a C # program.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After I had inserted the SASEGScripting.dll as a reference, I was able to do a lot with the SAS EG 7.1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, I always get the error message when executing the following code section:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;public static SAS.EG.Scripting.Application EGApp
{ get; private set; }

public static SAS.EG.Scripting.ISASEGProject EGProject
{ get; private set; }

EGProject = EGApp.Open(projectPath, password); //Error&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I want to open a project via the code, the following error message occurs:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;System.TypeInitializationException: Der Typeninitialisierer für "LibGit2Sharp.Core.NativeMethods" hat eine Ausnahme verursacht. ---&amp;gt; System.DllNotFoundException: Die DLL "git2-e0902fb": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.

   bei LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   bei LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
   bei LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   bei LibGit2Sharp.Core.NativeMethods.git_repository_init_ext(RepositorySafeHandle&amp;amp; repository, FilePath path, GitRepositoryInitOptions options)
   bei LibGit2Sharp.Core.Proxy.git_repository_init_ext(FilePath workdirPath, FilePath gitdirPath, Boolean isBare)
   bei LibGit2Sharp.Repository.Init(String path, Boolean isBare)
   bei SAS.EG.ProjectElements.InternalGitRepository..ctor(ProjectCollection pc)
   bei SAS.EG.ProjectElements.ProjectCollection..ctor(IMetadataService metadataService)
   bei SAS.EG.ProjectElements.ProjectCollection..ctor()
   bei SAS.EG.Scripting.Project..ctor()
   bei SAS.EG.Scripting.Application.Open(String fileName, String password)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Many thanks for the support!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 16:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/312654#M21112</guid>
      <dc:creator>StoneCat</dc:creator>
      <dc:date>2016-11-18T16:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Failure in running c# code SAS EG 7.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/312996#M21121</link>
      <description>&lt;P&gt;Well, it looks like EG cannot load a required DLL --&amp;gt;&lt;/P&gt;&lt;PRE&gt;System.DllNotFoundException: Die DLL "git2-e0902fb"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the DLL file "git2-e0902fb.dll" in the root directory of Enterprise Guide.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just add that DLL to your application and it should work.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 09:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/312996#M21121</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2016-11-21T09:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Failure in running c# code SAS EG 7.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313036#M21128</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16887"&gt;@AndreasMenrath﻿&lt;/a&gt;&amp;nbsp;-- adding that DLL to your app should do the trick. &amp;nbsp;This dependency was introduced in 7.11 with the addition of Program History (which relies on an internal git repository).&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 12:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313036#M21128</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-11-21T12:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Failure in running c# code SAS EG 7.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313128#M21129</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have added the reference in the project, but I get the same error message.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have put my entire SAS Enterprise Guide folder into the / bin / debug folder of my program, now it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you know which of the files the git2-e0902fb-reference needs, so I do not have to deliver the whole folder?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313128#M21129</guid>
      <dc:creator>StoneCat</dc:creator>
      <dc:date>2016-11-21T15:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Failure in running c# code SAS EG 7.1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313141#M21130</link>
      <description>&lt;P&gt;You can use an Assembly Resolver class/event to load the DLLs from the EG install as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a class like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    /// &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 SEG71AssemblyResolver
    {
        #region internal members
        internal static string PathToEGuideInstall = @"C:\Program Files\SAS\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;
        public static void Install(string path)
        {
            PathToEGuideInstall = path;

            // 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[] name = args.Name.Split(',');
            string path = System.IO.Path.Combine(PathToEGuideInstall, name[0] + ".dll");
            try
            {
                Assembly foundAssembly = Assembly.LoadFile(path);
                return foundAssembly;
            }
            catch (System.IO.FileNotFoundException)
            {
                return null;
            }
        }
    }
&lt;/PRE&gt;
&lt;P&gt;Then "install" this handler in the Main() function for your app:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  SAS.EG.Automation.SEG71AssemblyResolver.Install(EGinstall);&lt;/PRE&gt;
&lt;P&gt;Passing in the path where EG is installed on your system. &amp;nbsp;This class *should* direct the .NET runtime to load any assembly it needs from the installed app folder.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 16:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Failure-in-running-c-code-SAS-EG-7-1/m-p/313141#M21130</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-11-21T16:09:00Z</dc:date>
    </item>
  </channel>
</rss>

