I am trying to setup a test environment for Orleans that uses SQL Server for liveness. This is my server config file:
<?xml version="1.0" encoding="utf-8" ?>
<OrleansConfiguration xmlns="urn:orleans">
<Globals>
<Liveness LivenessType="SqlServer" DeploymentId="42783519-d64e-44c9-9c29-111111111133" DataConnectionString="Data Source=.\\SQLEXPRESS;Initial Catalog=Orleans;Integrated Security=True;" />
<!--<SeedNode Address="localhost" Port="11111" />-->
</Globals>
<Defaults>
<Networking Address="localhost" Port="11111" />
<ProxyingGateway Address="localhost" Port="30000" />
<Tracing DefaultTraceLevel="Info" TraceToConsole="true" TraceToFile="{0}-{1}.log">
<TraceLevelOverride LogPrefix="Application" TraceLevel="Info" />
</Tracing>
<Statistics MetricsTableWriteInterval="30s" PerfCounterWriteInterval="30s" LogWriteInterval="300s" WriteLogStatisticsToTable="true" />
</Defaults>
<Override Node="Primary">
<Networking Address="localhost" Port="11111" />
<ProxyingGateway Address="localhost" Port="30000" />
</Override>
</OrleansConfiguration>
When I use this config I get this error when running:
MembershipTableGrain cannot run without Seed node - please check your
silo configuration file and make sure it specifies a SeedNode element.
Alternatively, you may want to use AzureTable for LivenessType.
Parameter name: grain = MembershipTableGrain Exception =
System.ArgumentException: MembershipTableGrain cannot run without Seed
node - please check your silo configuration file and make sure it
specifies a SeedNode element. Alternatively, you may want to use
AzureTable for LivenessType.
and further up, the logs say that the Liveness is MembershipTableGrain (which is the default and requires a SeeNode). What am I missing here?
My silo config for SQLServer membership looks like this
<?xml version="1.0" encoding="utf-8"?>
<OrleansConfiguration xmlns="urn:orleans">
<Globals>
<SystemStore SystemStoreType="SqlServer" DeploymentId="YYYYY" DataConnectionString="Server=THESERVER;Database=Orleans;User ID=USER;password=PASSWORD;"/>
</Globals>
<Defaults>
<Networking Address="" Port="11111"/>
<ProxyingGateway Address="" Port="30000"/>
</Defaults>
</OrleansConfiguration>
No need to specify the liveness type. It figures it out by looking at the SystemStoreType.
The client config does need the gateway specified
<ClientConfiguration xmlns="urn:orleans">
<SystemStore SystemStoreType ="SqlServer"
DeploymentId="YYY"
DataConnectionString="Server=THESERVER;Database=Orleans;User ID=USER;password=PASSWORD;" />
<GatewayProvider ProviderType="SqlServer"/>
</ClientConfiguration>
You can also use programmable API for configuration, instead of XML.
I found the problem. That is not how to change the Liveness type. It should be like this:
<SystemStore SystemStoreType="SqlServer" DeploymentId="42783519-d64e-44c9-9c29-111111111133" DataConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Orleans;Integrated Security=True;" />
<Liveness LivenessType="SqlServer" />
Also, you must make sure to ref "Microsoft.Orleans.OrleansSqlUtils" NuGet package and run this SQL Create Script
Related
I've inherited an app that uses NHibernate and FluentNibernate to connect to an Oracle database. Unfortunately, I have no experience with NHibernate. The current connection string is like so:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=0000)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=servicename)));User Id={username};Password={password};
but now needs to switch over to LDAP (see the last code snippet).
My question, is it possible to make a change only to the web.config with an LDAP connection or will I need to add the Oracle.ManagedDataAccess and make some code changes?
It is my understanding that OracleClientConfiguration has been deprecated based on this page hence the part of the question about a new nuget package. Another note, there isn't a hibernate.cfg.xml file within the project (which I think is ok?) but wondering if this project isn't using the best practices for NHibernate. Any other hints or tips would be appreciated.
C# code:
private ISessionFactory GetSessionFactory()
{
var connectionString = LoginHelper.GetConnectionString(ConnectionStringSetting, LoginInfoSetting);
var iSessionFactory
= Fluently
.Configure()
.Database(OracleClientConfiguration.Oracle10.ConnectionString(connectionString))
.Mappings(e => e.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.BuildSessionFactory();
return iSessionFactory;
}
Web.config (there no other references to NHibernate in the Web.config. There are some references to dependentAssembly in other dll.config files):
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<configSections>
<configuration>
What I (think I) need in the Web.config is something like so:
<oracle.dataaccess.client> <!-- or <oracle.manageddataaccess.client>? -->
<version number="*">
<LDAPsettings>
<LDAPsetting name="DIRECTORY_SERVERS" value="" />
<LDAPsetting name="DIRECTORY_SERVER_TYPE" value="" />
<LDAPsetting name="DEFAULT_ADMIN_CONTEXT" value="" />
</LDAPsettings>
<settings>
<setting name="NAMES.DIRECTORY_PATH" value="" />
<setting name="LDAP_ADMIN" value="" />
</settings>
</version>
</oracle.dataaccess.client>
EDIT 1:
Contents of ldap.ora file:
DIRECTORY_SERVERS=(ldap:XXX)
DEFAULT_ADMIN_CONTEXT="dc=Oracle,dc=com"
DIRECTORY_SERVER_TYPE=ad
Here is what I did in order to get this to work...
In the Oracle folder structure, navigate to the Network folder.
Add the following files (should be able to copy and paste another folder down called Sample):
sqlnet.ora
ldap.ora
tnsnames.ora
sqlnet.ora (the key here was adding LDAP to the beginning of the list):
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (LDAP, TNSNAMES, EZCONNECT)
ldap.ora:
DIRECTORY_SERVERS=(ldap:XXX:XXX)
DEFAULT_ADMIN_CONTEXT="dc=oracle,dc=com"
DIRECTORY_SERVER_TYPE=XX
tnsnames.ora:
No change was required; left as default
Connection string:
<add name="connection" connectionString="Data Source=YourDataSource"/>
<!-- might need to add a username/password -->
According documentation it should be this:
<LDAPsettings>
<LDAPsetting name="DIRECTORY_TYPE" value="AD" />
<LDAPsetting name="DEFAULT_ADMIN_CONTEXT" value="dc=Oracle,dc=com"/>
</LDAPsettings>
Or use
<settings>
<setting name="TNS_ADMIN" value="C:\oracle\work"/>
</settings>
and specify LDAP settings in C:\oracle\work\ldap.ora file (in conjunction with C:\oracle\work\sqlnet.ora file).
I don't think it is still valid but have a look at ODP.NET Managed library does resolve alias, but 32-bit library does
You can modify the config file with a simple text editor or use the config tool OraProvCfg.exe. Would be like this:
OraProvCfg.exe /action:config /product:odpm /frameworkversion:v4.0.30319 /providerpath:C:\oracle\product\12.1\Client_x64\odp.net\managed\common\Oracle.ManagedDataAccess.dll /set:settings\TNS_ADMIN:C:\oracle\network\admin
OraProvCfg.exe /action:config /product:odpm /frameworkversion:v4.0.30319 /providerpath:C:\oracle\product\12.1\Client_x64\odp.net\managed\common\Oracle.ManagedDataAccess.dll /set:LDAPsettings\DIRECTORY_TYPE:ad
Note, you have a OraProvCfg.exe for 32-bit (x86) and for 64-bit. Run the one which matches to your application, (or simply run both).
I have consolidated the connection string information for a number of C# .NET solutions that are in my possession. Previously, each project was storing its connection string in its own format, requiring me to modify several files for each installation of the software.
Only one remaining solution is giving me trouble. This particular solution uses Castle Windsor 2.0, ActiveRecord 2.0 and NHibernate 2.1. The code reads its configuration from an XML file. I wish to remove the connection string from the config file and set it programmatically in the code.
Here is the relevant section of code that initiates Windsor:
windsorContainer = new WindsorContainer(new XmlInterpreter(xmlFileName));
windsorContainer.Resolve<IWindsorConfigurator>().Configure(windsorContainer);
logger = windsorContainer.Resolve<ILogger>();
Here are the contents of the XML file:
<?xml version="1.0"?>
<configuration>
<properties>
<connectionString>Server=*****;Database=*****;User Id=*****;Password=*****</connectionString>
</properties>
<facilities>
<facility id="logging" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging" loggingApi="log4net" configFile="Configs/log4net.config" />
<facility id="atm" type="Castle.Facilities.AutomaticTransactionManagement.TransactionFacility, Castle.Facilities.AutomaticTransactionManagement" />
<facility id="arfacility" type="Castle.Facilities.ActiveRecordIntegration.ActiveRecordFacility, Castle.Facilities.ActiveRecordIntegration" isDebug="false" isWeb="false">
<!-- Configure the namespaces for the models using Active Record Integration -->
<assemblies>
<item>ChronoSteril.Application</item>
</assemblies>
<config>
<add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
<add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="connection.connection_string" value="#{connectionString}" />
<add key="hibernate.cache.provider_class" value="NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache" />
<add key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />
<add key="hibernate.expiration" value="60" />
</config>
</facility>
</facilities>
<components>
<component id="windsorConfigurator" service="ChronoSteril.Application.IWindsorConfigurator, ChronoSteril.Application" type="ChronoSteril.WinApp.ClarionIntegrationWindsorConfigurator, ChronoSteril.WinApp" />
</components>
I am not familiar with Windsor. During my Google tour, I did see some code that adds facilities programmatically, but those examples were not valid for my version of Windsor (I assume).
Question: Can anyone guide me in removing the connection string information from the XML file and allow me to set it in the code?
Thank you!
I managed to accomplish my intention. It is not ideal, but will work until the code base is rewritten. (I cannot wait to drop the existing code like a bad dream.)
Patrick's comment, under my initial question, let me to refine my search criteria, which yielded the thread located here.
My XML file remains the same, except that I use bogus values for the connection string information. I will never need to modify these, and they do not reveal any valid connection information. This was my intention. I still have not discovered how to successfully remove the ActiveRecord configuration from the XML file and configure using code.
I now call a method that contains the following code:
ISessionFactoryHolder sessionFactoryHolder = ActiveRecordMediator.GetSessionFactoryHolder();
NHibernate.Cfg.Configuration configuration = sessionFactoryHolder.GetConfiguration(typeof(ActiveRecordBase));
connectionString = ReadConnectionString();
configuration.SetProperty("connection.connection_string", connectionString);
This works for me. I hope that it can also help someone else who is in the same position as I was.
I'm doing some work in Visual Studio 2012 Express Edition. I have added an App.config XML file as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
The first thing that happens is a warning comes up that says "The 'configuration' element is not declared". Does anyone know why this is happening? It looks like elements can not be declared inside of until this is resolved.
Thanks!
This is the entire XML:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Version" value="779" />
<add key="TimeOut" value="60000" />
<add key="LogFileName" value="Log.txt" />
<!-- your Developer Id with eBay -->
<add key="Environment.DevId" value="" />
<!-- your Application Id with eBay -->
<add key="Environment.AppId" value="" />
<!-- your Application Certificate with eBay -->
<add key="Environment.CertId" value="" />
<!-- API Server URL -->
<!-- For production site use: https://api.ebay.com/wsapi -->
<!-- For Sandbox use: https://api.sandbox.ebay.com/wsapi -->
<add key="Environment.ApiServerUrl" value="https://api.sandbox.ebay.com/wsapi" />
<!-- EPS Server URL -->
<!-- For production site use: https://api.ebay.com/ws/api.dll"/-->
<add key="Environment.EpsServerUrl" value="https://api.sandbox.ebay.com/ws/api.dll" />
<!-- eBay Signin URL -->
<!-- For production site use: https://signin.ebay.com/ws/eBayISAPI.dll?SignIn -->
<!-- https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn -->
<add key="Environment.SignInUrl" value="https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn" />
<!-- ViewItem URL -->
<!-- For production site use: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item={0} -->
<add key="Environment.ViewItemUrl" value="http://cgi.sandbox.ebay.com/ws/eBayISAPI.dll?ViewItem&item={0}" />
<!-- token is for both API server and EPS server -->
<add key="UserAccount.ApiToken" value="" />
<!-- eBay site ID -->
<add key="UserAccount.eBayUserSiteId" value="0" />
<add key="logexception" value="true"/>
<add key="logmessages" value="true"/>
<add key="logsdkmessages" value="true"/>
<add key="logsdk" value="true"/>
<add key="logfile" value="Log.txt"/>
<!-- Rule Name-->
<add key="RuName" value=""/>
<!-- Set this if you access eBay API server behind a proxy server-->
<add key="Proxy.Host" value =""/>
<add key="Proxy.Port" value =""/>
<!-- set proxy server username/password if necessary-->
<add key="Proxy.Username" value=""/>
<add key="Proxy.Password" value=""/>
Go to XML menu (visual studio top menu item) choose schemas and find for DotNetConfig.xsd and choose Use this schema.
Your problem will resolve for sure
<configuration xmlns="schema URL">
<!-- configuration settings -->
</configuration>
do changes,like above & try
I had the same issue. It is not an error, it is simply a warning; so your application should still compile. I used the following simple config file and the warning is still produced.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime
version="v4.0"sku=".NETFramework,
Version=v4.5"/>
</startup>
</configuration>
It is an issue that has been raised on the MSDN website, but it does not seem to have been satisfactorily resolved. See link below:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/18a1074f-668f-4fe3-a8d9-4440db797439
I had to
-> Go to XML menu (visual studio top menu item) choose schemas and select DotNetConfig.xsd AND RazorCustomSchema.xsd AND EntityFrameworkConfig_6_1_0.xsd
I just had this warning popup inside an autogenerated xml file while working on a xaml project.
Using Debug->Clean Solution and Debug->Rebuild Solution fixed it. Might want to try that before getting fancy with the schemas.
Visual Studio 2013 Express Edition is missing the DotNetConfig.xsd (https://connect.microsoft.com/VisualStudio/feedback/details/817322/dotnetconfig-xsd-files-not-present-in-vs-2013-express-for-desktop).
So to get rid of the warning in VS 2013 Express:
get a copy of DotNetConfig.xsd from another system or from the web (I used https://gist.github.com/eed3si9n/5dd7dd98ad2b3f668928b23477de35a3)
download to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Xml\Schemas
add the schema following Ramakrishna's answer
The warning should be gone.
Choose use this schema. DotNetConfig.xsd
XLM Menu..... Visual Studio
Works perfectly.
I was having less space on my drive which might have resulted in incomplete loading of my application solution. This "the-configuration-element-is-not-declared" problem got solved after i created some space on my drive.
I also got the same warning. After thinking about for some time I realized my error working with SQL (MS SQL).
Warning: the 'configuration' element is not declared
Using C#
App.Config code:
<connectionStrings>
<add name="dbx" connectionString="Data Source=ServerNameHere;Initial Catalog=DatabaseNameHere;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
*this calls out the database name in the connectionStrings, when I plugged in my SQL code as a practice I always use the database name, schema, then table. This practice didn't carry over well in Visual Studio as I am a beginner. I removed the db name from my SQL syntax and only called from the schema, data table. This resolved the issue for me.
Form.CS:
using (SqlCommand cmd = new SqlCommand("SELECT * FROM [DatabaseName].[Schema].[TableName] WHERE [MEPeriod] = '2020-06-01'", con))
Updated to:
using (SqlCommand cmd = new SqlCommand("SELECT * FROM [Schema].[TableName] WHERE [MEPeriod] = '2020-06-01'", con))
This worked for me, I hope this is found as useful.
I am trying to add a set of URL Rewriting rules but only to the published version of the web site I'm developing.
I find all sorts of examples if i want to change say the connection string value, but I cannot find an example of how to add something that does ot already exists in the main web.config.
What I need is to add the rewrite node under the system.WebServer.
All you need is to use xdt:Transform="Insert" attribute within a tag that you want added during transformation. Read more about it here: http://msdn.microsoft.com/en-us/library/dd465326.aspx
You can take the below sample as a starting point (which is my Web.Release.config file):
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- Enable static content caching in release mode -->
<system.webServer xdt:Transform="Insert">
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="5.00:00:00" cacheControlCustom="public" />
</staticContent>
</system.webServer>
</configuration>
I'm trying to use xml configuration file in my project. Now it looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="replication" type="Project.Replication.ReplicationConfigSection, Project.Replication" />
<section name="processing" type="Project.Processing.ProcessingConfigSection, Project.Processing" />
</configSections>
<replication>
<streams>
<stream name="STREAM_DATA_14360" />
</streams>
</replication>
<processing dataStream="STREAM_DATA_14360" />
</configuration>
It works OK, but I'm confused with duplicates in it ("STREAM_DATA_14360").
Can you remind me, how to create variables in XML or something for data reusing to be acceptable in application configuration?
UPDATE:
In real life my configuration has much more sections. There is a value, which apeears in many of this sections: STREAM_DATA_14360. So I want to be able to change this value only in one place of config file, and in other places to use reference to it.
Speed of changing configuration - is the first reason for it.
Size of a file is a second, because values can be huge: STREAM_INFO_FUTURE_SESSION_CONTENTS_12421 (that is third-party names)
You can simply add this value in <appSettings> and access it as you are saying.
You can do this as below:
<appSettings>
<add key="StreamName" value="STREAM_DATA_14360"/>
</appSettings>
In the code, you can access it as below:
string streamName = ConfigurationManager.AppSettings["StreamName"];
Make sure to add reference to System.Configuration assembly before using this.
XML doesn't have any native expansion macros or templating - any scenario would require that you do a preprocess step or have the code that reads the config involved in substituting the value.
If those aren't redacted names though, it seems a simple search/replace would solve the problem without much of a concern on false positives.
You could put something together with T4 templates as a preprocessor, whether that's worth it really depends on how often you expect to modify this file.
It should also be possible to shoehorn the web.config transformation engine into doing the replacements, but you may have to write some hosting code for the XDT engine depending on how your config file is setup.
Apart from using external code that might (or might not) facilitate your life, you can define your own classes that inherit from ConfigurationSection, wherein you define and encapsulate your key/value pairs and use the ConfigurationProperty attribute.
Have look at http://msdn.microsoft.com/en-us/library/2tw134k3.aspx for more info on How to: Create Custom Configuration Sections Using ConfigurationSection.
EDIT: you can make references in xsd (check here)
Thanks for your answers. I agree with Mark, there's no support of variables or references in XML. But, in my case there's much simpler solution. I feel stupid now, but hope that it will help another slowpoke too.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="global" type="Project.GlobalConfigSection, Project" />
<section name="replication" type="Project.Replication.ReplicationConfigSection, Project.Replication" />
<section name="processing" type="Project.Processing.ProcessingConfigSection, Project.Processing" />
</configSections>
<global>
<streamNames>
<streamName name="STREAM_DATA_14360" id="1"/>
</streamNames>
</global>
<replication>
<streams>
<stream nameId="1" />
</streams>
</replication>
<processing dataStreamId="1" />
</configuration>
Consequence: need to edit code to use global section as a source of all long names
Advantage: fast renaming, reusability of values