locked
C# Components Connection String Using BTDF RRS feed

  • Question

  • Hi,

    I Have Generated Bam Classes Using Generate BAM APi for Buffere Event Stream. SO i see that one of the Event Stream has 

     public static BufferedEventStream GetEventStream()
            {
                return new BufferedEventStream("Integrated Security=SSPI;Data Source=.;Initial Catalog=BizTalkMsgBoxDb", 1);
            }

    In an Environment where SQL is present in one Server and Biztalk is present in other server. i dont think this configuration works?

    I know in C# we can use an app config file and pass it but How can i do it in BTDF?

    Please let me know if am wrong on the above

    Tuesday, May 10, 2016 7:53 PM

Answers

  • Yes, you can create settings.settings file that will hold configurable data. Visual Studio creates the files Settings.settings and Settings.Designer.settings that contain the singleton class Settings inherited from ApplicationSettingsBase. You can access this class from your code to read/write application settings.

    The applicationSettings are readonly during runtime. You can set/modify them either via a text editor in the app.config file directly, but it is recommended to open the project properties in Visual Studio and select the "Settings" tab. It is important to set the right scope:

    If the settings apply to the entire application (for all users), select "Application" as scope.
    If every user should have individual settings (bound to the user profile), then select "User"


    it will add the following to the application's app.config file:

    <configuration>
        <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="XXX.EIE.BAMAPI.BAMAPISettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            </sectionGroup>
        </configSections>
        <applicationSettings>
            <XXX.EIE.BAMAPI.BAMAPISettings>
                <setting name="BAMInstrumentation" serializeAs="String">
                    <value>False</value>
                </setting>
                <setting name="BAMConnectionString" serializeAs="String">
                    <value>Integrated Security=SSPI;Data Source=.;Initial Catalog=BizTalkMsgBoxDb</value>
                </setting>
            </XXX.EIE.BAMAPI.BAMAPISettings>
        </applicationSettings>
    </configuration>

    you can read its value in the application easily via the following code:

    connectionString = BAMAPI.BAMAPISettings.Default.BAMConnectionString;
    Regarding BTDF, When u compile the c# library, all the settings in Settings.Settings are integrated into the DLL.
    You can add it as a Component. Look in the documentation for the full reference: http://www.tfabraham.com/BTDFDocs/V5_0/NETAssemblies.html

    Make sure you have both the PropertyGroup property IncludeComponents set to true and the dll configured in a ItemGroup as the Component type.

    Set the IncludeComponents property to true
    <PropertyGroup>
     ...
     <IncludeComponents>true</IncludeComponents>
     ...
    </PropertyGroup>
    then
    <ItemGroup>
     <Components Include="yourC#projectname.dll">
       <LocationPath>..\yourC#projectname\bin\$(Configuration)</LocationPath>
     </Components>
    </ItemGroup>



    Rachit Sikroria (Microsoft Azure MVP)

    • Proposed as answer by Angie Xu Thursday, May 19, 2016 10:19 AM
    • Marked as answer by Angie Xu Thursday, May 19, 2016 10:19 AM
    Wednesday, May 11, 2016 7:57 PM
    Moderator

All replies

  • sorry to say but your question isn't clear to me, please enlighten us with little more details and let's find the correct solution for it.

    "I Have Generated Bam Classes Using Generate BAM APi for Buffere Event Stream." - so what exactly this is doing? can you please elaborate a bit

    SO i see that one of the Event Stream has 

     public static BufferedEventStream GetEventStream()
            {
                return new BufferedEventStream("Integrated Security=SSPI;Data Source=.;Initial Catalog=BizTalkMsgBoxDb", 1);
            }

    In an Environment where SQL is present in one Server and Biztalk is present in other server. i dont think this configuration works?" - What exactly isn't working, are you trying to connect to SQL server on another box then you need to pass proper Data Source, Username, Password. Are you getting any error in event viewer.

    "I know in C# we can use an app config file and pass it but How can i do it in BTDF?" - so here what exactly are you passing and how does Deployment framework comes in to play?

    trying to understand the bigger picture of your problem...

    Tuesday, May 10, 2016 8:28 PM
  • Yes, you can create settings.settings file that will hold configurable data. Visual Studio creates the files Settings.settings and Settings.Designer.settings that contain the singleton class Settings inherited from ApplicationSettingsBase. You can access this class from your code to read/write application settings.

    The applicationSettings are readonly during runtime. You can set/modify them either via a text editor in the app.config file directly, but it is recommended to open the project properties in Visual Studio and select the "Settings" tab. It is important to set the right scope:

    If the settings apply to the entire application (for all users), select "Application" as scope.
    If every user should have individual settings (bound to the user profile), then select "User"


    it will add the following to the application's app.config file:

    <configuration>
        <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="XXX.EIE.BAMAPI.BAMAPISettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            </sectionGroup>
        </configSections>
        <applicationSettings>
            <XXX.EIE.BAMAPI.BAMAPISettings>
                <setting name="BAMInstrumentation" serializeAs="String">
                    <value>False</value>
                </setting>
                <setting name="BAMConnectionString" serializeAs="String">
                    <value>Integrated Security=SSPI;Data Source=.;Initial Catalog=BizTalkMsgBoxDb</value>
                </setting>
            </XXX.EIE.BAMAPI.BAMAPISettings>
        </applicationSettings>
    </configuration>

    you can read its value in the application easily via the following code:

    connectionString = BAMAPI.BAMAPISettings.Default.BAMConnectionString;
    Regarding BTDF, When u compile the c# library, all the settings in Settings.Settings are integrated into the DLL.
    You can add it as a Component. Look in the documentation for the full reference: http://www.tfabraham.com/BTDFDocs/V5_0/NETAssemblies.html

    Make sure you have both the PropertyGroup property IncludeComponents set to true and the dll configured in a ItemGroup as the Component type.

    Set the IncludeComponents property to true
    <PropertyGroup>
     ...
     <IncludeComponents>true</IncludeComponents>
     ...
    </PropertyGroup>
    then
    <ItemGroup>
     <Components Include="yourC#projectname.dll">
       <LocationPath>..\yourC#projectname\bin\$(Configuration)</LocationPath>
     </Components>
    </ItemGroup>



    Rachit Sikroria (Microsoft Azure MVP)

    • Proposed as answer by Angie Xu Thursday, May 19, 2016 10:19 AM
    • Marked as answer by Angie Xu Thursday, May 19, 2016 10:19 AM
    Wednesday, May 11, 2016 7:57 PM
    Moderator
  • Hi Rachit,

    Thanks for the above article.

    It works for me like we store it an appocnfig file and change it according to environment but is there any chance like how we do in BTDF. if its a Dev Server take this connection String and if its in a Test Environment take this Connection.

    in BTDF we can configure it in Settings Generator file and take the appropriate settings for our send ports and receive ports etc

    How can It actually read that BTDF setting into the Components Project in the above case?

    or is there any Settings file like that in C# which I can use?

    Friday, May 20, 2016 11:59 AM