I am making a WPF application in Visual Studio 2015. The database layer is using Entity Framework, which generated a connection string in the app.config file. The database connection works and the app runs. Nonetheless, at design-time, Visual Studio complains about there being "no connection string named in the application configuration file" -- but there is.
Since it seems to resolve itself as run-time, I ignored the warnings up until now. However, now the issue is interfering with the design process -- Visual Studio is claiming not being able to make instances of classes that use the connection.
I have tried moving the app.config around into various positions in the project structure, renaming it to match the app's name, cleaning and rebuilding the project.
I believe that, at design-time, not all files are referencing the same app.config. Something about my project structure must be off.
How can I determine and/or change the path that EF is following to the app.config?
The XML from the app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<connectionStrings>
<add name="MYAPPSNAME" connectionString="metadata=res://*/MYDBNAME.csdl|res://*/MYDBNAME.ssdl|res://*/MYDBNAME.msl;provider=MySql.Data.MySqlClient;provider connection string="server=193.169.2.123;user id=devs;password=*********;persistsecurityinfo=True;convertzerodatetime=True;database=MYDBNAME"" providerName="System.Data.EntityClient" /></connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
I found a solution to my problem here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/257ca21a-15cd-4d21-84df-79cc6bcbe546/getting-a-no-connection-string-named-cound-be-found-in-the-application-config-file-error-and-i?forum=wpf
Essentially, I add the following to the constructors of classes that establish a database connection; it checks if the project is in Designer Mode, and if so, returns before trying to make a database connection.
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
return;
In this way, I avoid the issue of Visual Studio trying to make a db connection from the designer, so it doesn't complain and allows me to design freely. At run-time, still no issues. :)
Still not entirely sure of the source of the problem -- I am still guessing that at design-time, the app.config file is not fully read/parsed, so the designer is complaining about not having enough information to construct such classes.
If it shows up in Solution Explorer then properties will show you where it is. You should be able to open and edit it right there.
If app.config is not in Solution Explorer it should be in the same folder has the MainWindow. Make sure you also add (Add Existing) in the project in Visual Studio. The file should show up in the Solution Explorer.
Related
We are moving a webforms application, primarily .NET 4.7.2, into Azure. A number of ASPX pages incorporate React sections. All works fine in the current Windows Server environment and running through Visual Studio, but when running in Azure, the package.json file cannot be found even though the file is in the correct location. Information that I've found indicates that this may be due to missing handler mappings. I have found a number of solutions that indicate adding settings in the web.config file may solve the problem:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
However, this makes no difference; a 404 error is still returned.
Our Azure knowledge is minimal, but perhaps it would be better to add the handler mappings in the Azure portal? If this is the case, what should be entered as the script processor?
Any help will be welcome!
If you haven't already tried this, try restarting Visual Studio. Then, from the build menu, hit 'clean solution,' and then 'rebuild solution.'
Please forgive my ignorance, but I can't find any resources describing to how to obtain a reference to an OSGi declared datasource without hardcoding the name in the Spring XML definition.
I'm using Talend ESB SE Runtime (6.5.1), and trying to create a route that will be reused with different osgi data sources as the referenced datasource for the route.
If, in the Spring configuration I declare
<osgi:reference id="dataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=myDataSourceName)" />
this works. However, I can't see any way of parameterising this, since when I try using
<osgi:reference id="dataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=${app.datasource.name})" />
the karaf log complains that it can't find a service called ${app.datasource.name} which it clearly isn't going to find.
If parameters can't be used in the filter for osgi references, then I could configure this in Java, but I can't see anywhere how I get from a Camel Context registry to the underlying OSGi registry - which the osgi:reference element does in the Spring XML.
If anyone can point me in the right direction here, that would be great, since I suspect I may be misunderstanding how the various components function.
Thanks!
I think it's problem of configuring property placeholder, cause there must be value of your app.datasource.name property in log, not property name. Try to use spring xml config like this.
Okay, so I have been trying all day to sort this out. My boss has assigned me a new task: Take this template: https://github.com/DavidKk/ngAdmin , figure out how AngularJS works, figure out how Spring works, how does Hibernate work, how does Maven work for project builds, tests etc, implement a basic CRUD example inside that template on a MySQL database, deploy on Tomcat.
So, first, this is a lot of stuff all at once, stuff that I have not ever worked with, maybe with Hibernate and a bit with JPA, and he wants all this stuff sorted out by the end of the week, when we will talk more about the project with the client, so we can tell him what approach we will take on the development process.
I took a look at Spring, used Spring Initializr: https://start.spring.io/ to make a basic project, used the jar command tool to make a WAR file, deployed it on tomcat, and it worked. I have used these two, because IntelliJ Commuity has none of these implemented, unless you pay for the Ultimate edition.
I took a look at this CRUD example: http://www.concretepage.com/spring-4/spring-mvc-4-rest-angularjs-hibernate-4-integration-crud-tutorial-with-ngresource-example , and made it work, and understood how Spring uses dependency injection, how Hibernate persists objects into the database, and how AngularJS provides the single-page layout that my client has asked for.
Now, my problem is, this template has a whole different directory structure, and if I move files around nothing is going to work. Starting everything from scratch is not an option, we take a front end template, modify it a little bit, develop the back-end stuff for client and server. What I do not understand is how I could ever use this with Spring, which has a whole different directory structure, or with Tomcat, which expects different stuff too, or it will throw me a 404. From what I have seen, this project has been built with Grunt, so I do not know if there is any way to go from Grunt to Maven, and have it still work. I don't really know what to do, and I must finish this by the end of the week. Any help would be appreciated, thanks.
The template you show is only for the front-end.
Create a project with spring initializer.
You'll have {directory}/src/main/java and other stuff.
Create {directory}/client/
Put the ngAdmin stuff in it.
ngAdmin uses grunt to build the client, and generate the site in the dest directory. This will be {directory}/client/dest/
Configure maven-frontend-plugin to install js stuff and run grunt when building with maven.
Add maven-resource-plugin configuration to copy from {directory}/client/dest/ to ${project.build.directory}/client
Configure maven war plugin to include this directory
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<attachClasses>true</attachClasses>
<webResources>
<resource>
<directory>${project.build.directory}/client</directory>
</resource>
</webResources>
</configuration>
</plugin>
This way, when you build the war, the client should be in it (unzip the war and check)
Then you will have some config to tell spring-mvc where exactly to find those, but I don't have that on hand.
Hope this help.
I have been working with .NET for about 2 years now and I want to build a complete website out of everything I have learned so far. Essentially I would like the site to represent my portfolio.
Here are my skill set in short:
Core Language:
- .NET C#, ASP MVC3, Javascript, AngularJS, SASS
Tools
- Visual Studio 2013, AnkhSVN, CruiseControl
DB
- MS SQL, Postgres, ORACLE
I would like to know the list of things I would need to make this happen. I looked around and I find information in bits an pieces but can't seem to get the whole picture, starting from development of a workable cshtml page to its deployment to a webpage.
Here's what I know so far:
- I need a domain name
- I need a host
..................that's it.. :(
Since no one bothered to look at the big picture and were only focused on answering when provided a specific question, I talked with some experts on the topic and figured how I could get my site up and running.
Right now I'm running two test sites, one on Windows Azure and another on regular GoDaddy host.
Windows Azure provided 30 day trial period and publishing was REALLY EASY. Please note that I found pricing to be a little steep for a test project.
Steps:
Register at http://azure.microsoft.com/en-us/pricing/free-trial/
Develop your test web project as usual.
Right Click and Publish Select Profile->"publish target" as "Windows Azure
Websites" and follow instruction there on.
Click Publish
Things were a little lengthy for GoDaddy.
Steps:
Get domain name and hosting
Develop your test web project as usual.
Right Click and Publish Select Connection -> "Publish Marget" as FTP and fill in the FTP information as provided by the host.
Click Publish
For GoDaddy you might run into some config issue, so make sure you turn off customErrors so you can debug your issue
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
PS Regards to charlietfl for the FTP suggestion.
I have a ClickOnce application that checks a server for a new version on startup.
I recently deployed a new version (2.0.0.0) whilst leaving the old version (1.9.9.9) on the server.
On startup version 2 will inform the user that a new version of available and download 1.9.9.9.
Is there a reason this could be happening? I assumed that ClickOnce would look at the version numbers alone when deciding if a version was newer or not.
Thanks
EDIT - this is the publish version
EDIT TWO
Thanks for the replies guys.
The app is published by visual studio. It has placed a .application file in the root which contains info such as the following:
<assemblyIdentity name="CokeAudit.application" version="2.0.0.0" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="x86" xmlns="urn:schemas-microsoft-com:asm.v1" />
The .application file that exists on the server (which I havent updated to the new version yet) contains a .application file in the root which contains details such as:
<assemblyIdentity name="CokeAudit.application" version="1.9.9.9" publicKeyToken="4c4bf139090ca52a" language="neutral" processorArchitecture="x86" xmlns="urn:schemas-microsoft-com:asm.v1" />
The only thing I can see that is different, aside from the version number, is the public key info. Could this be due to the fact that between version 1.9.9.9 I had to disable the signing of the application as the certificate expired? Would this cause the upgrade issue?
I did not, at any stage, sign the app with an actual 'proper' certificate - it was always a test one generated by visual studio.
ClickOnce does not look at the version numbers -- it simply looks at the application manifest file in the top level directory of your ClickOnce repository. This is important when, for example, you need to do an enforced rollback of a release.
Make sure the application manifest in the top level is the same as the application manifest in the 2.0.0.0 directory under Application files -- if it's not, just copy the manifest up to the top level.
How are you publishing your application? IF you are using Visual Studio, it will place the new deployment manifest (.application file) in the root; otherwise Richard Dunlap is right, you will need to do that yourself.
The other case where I've seen people have this problem is when caching is turned on on the webserver. (I think I've only heard of that with Unix or Apache servers.)