.Net CORE class library project configuration file and Startup.cs - configuration

I added a class library project to my .net core 5 solution. I realized that it doesn't contain configuration files that other project types normally do, such as appsettings.json. And it doesn't have the Startup.cs either. I wonder if I can simply add them into the project? If I do, will they work just like they do in other project types? I need this project to be able to read from configuration file and load services and pipelines in Startup.cs.

Related

How do I import Primefaces 6.0 source as maven project in Eclipse?

I followed Building From Source https://github.com/primefaces/primefaces/wiki/Building-From-Source instructions. Building the SNAPSHOT version project from command works well.
However, importing it into eclipse using the Existing Maven Projects wizard gives me a lot of errors in the Problems view. I fixed the lifecycle mappings by setting all to ignore.
I realized the generated source code in the target/generated-sources/maven-jsf-plugin directory but it was not picked up by the m2e plugins as a source folder automatically. So I included it into the eclipse build path manually. But then again, many compile errors show up in the generated code.
Does anybody use eclipse as IDE for primefaces development? How do you setup the eclipse project to develop primefaces?
The eclipse project uses Java Compiler compliance level 1.5 derived from the pom.xml maven-compiler-plugin settings. Setting the Java Compiler compliance level to 1.6 solved the issue for me.

ServiceStack as Windows Service with Razor - Setup Project

I have a servicestack project using razor exposed through a windows service, and need to create a setup project to install it (as opposed to the batch files in the demo's I've seen).
Any suggestions on how to accomplish this with a packaged setup project? Looking at the folder where the windows service files were installed, it only has the dll's, not the razor views... so I coped those over, and now I see this:
Not sure why you're getting that error, can you double-check that you're deploying the orignal Razor source files and not some interim build.
Otherwise some other options for hosting Razor is to change them to Embedded Resources, that way the original Source files get compiled into your .dll so you don't need to deploy them to your project.
Or you can pre-compile Razor Views that way the implementation is compiled into the .dll.

Web.config gone in Asp.net 5 mvc6, how about non web config?

Context
In asp.net 5 vNext MVC6, Web.config is gone, in favor of json file as config. However, in my web.config, I have settings of WCF clients, trace listeners of System.Diagnostics and Essential.Diagnostics, and these components (WCF clients and trace listeners apparently could not read json at startup). So in vNext Microsoft has abandoned System.Configuration apparently.
Question
Are there some migration path so I don't have to totally rewrite in order to make these components read config info at startup?
Short answer: It works fine in ASP.NET Core MVC on .NET Framework (4.5.1+), put your settings in app.config, but doesn't work in ASP.NET Core MVC on .NET Core.
Longer answer:
ASP.NET Core can run on both .NET Framework and .NET Core, so I guess the migration path is to continue using .NET Framework for now.
For System.Diagnostics, and Essential.Diagnostics (which I contribute to), I have been able to at least get a demo of this working in ASP.NET Core running on .NET Framework (not .NET Core).
In the .NET Framework, TraceSource, etc still load from the config. In an ASP.NET Framework project there will be an app.config file (not web.config) where you need to put the configuration sections.
Note: Just Building (Debug > Start new instance) does not update the .exe.config file in the bin directory; you need to do a Clean or Rebuild, and then Debug (or delete the output bin folder).
You can write to TraceSource either directly (for legacy code), or via the new Microsoft.Extensions.Logging, with the Microsoft.Extensions.Logging.TraceSource provider configured. (The new interface includes some nice hierarchical support features.)
Either way, it will load and write to the configured TraceSource, which can output to system TraceListeners.
You can also configure additional listeners from Essential.Diagnostics (although the RollingFileTraceListener wasn't correctly handling the {AppData} token in the filename, so I had to hard code the path to C:\Temp\Logs).
The above also works in a console app (simpler), with the .NET Framework 4.5.1 and above.
There is some example code in Essential.Diagnostics: https://essentialdiagnostics.codeplex.com/SourceControl/latest#Examples/TestAspNetCoreOnNetFx/Controllers/HomeController.cs
I suspect it may be similar with WCF: the .NET Framework version should continue to work, using app.config, but the .NET Core implementation may be a shell only.
On .NET Core:
Note that Essential.Diagnostics will not work on .NET Core (it doesn't support it yet, as at Feb 2017), and most system TraceListener classes are also not supported.
The only one that is is the TextWriterTraceListener, which I have got working with a manually created TraceSource, however from looking at the .NET Core source code, I don't think there is a way for TraceSource to automatically load configuration yet.

Glassfish Applications Not Starting

I was just reading about using libraries in glassfish. That is, put jar files in a 'centralized' location so that it can be accessed from different web applications. domains-dir/lib/ext is one of such locations. I put some jar files there and restarted the server. The restart was successful but no application would load; not even the admin console. I investigated this and found the culprit to be the primefaces jar file I put. On removing it, glassfish worked properly. I've tried versions 3.1 and 3.2 of primefaces and the results are the same. On checking the server log, I find that, with primefaces in the ext folder, the class javax.faces.context.PartialViewContextFactory fails to load. Any idea what might be causing this. I should probably try the other library locations like domains-dir/lib/ but I'm curious.
By the way, I'm working on a windows 7 OS and using glassfish 3.1.1
Thanks.
Just put the libs in domains-dir/lib/.
From the Glassfish manual:
To use the Common class loader, copy the JAR files into the domain-dir/lib or as-install/lib
directory or copy the .class files (and other needed files, such as .properties files) into the
domain-dir/lib/classes directory, then restart the server.
Using the Common class loader makes an application or module accessible to all applications
or modules deployed on servers that share the same configuration.However, this accessibility
does not extend to application clients.
More information about classloading in Glassfish can be found here.

Spring 3 MVC on JBoss 5.1: ConflictingBeanDefinitionException

When I try to deploy my application on JBoss 5.1 Spring 3 MVC throw me this stack trace: http://pastebin.com/Aah386PJ
Telling me that I have two definition of the same bean in two different packages. The thing is I don't have this IntershipConfigurationController in the controller package, but I have it in controller.internshipConfiguration. I previously add it under the root of controller but I deleted it from SVN and it doesn't appear anymore in the tree.
I cleaned JBoss, Eclipse's project, tried to redeploy it, to restart JBoss, Eclipse, etc. but I can't get this project working while my mates with the same repository can run it with no issue.
I don't know what to do this is really annoying.
I know this can be frustrating sometimes but you might want to know why this could happen. Spring annotation based ant path matcher checks for the class-path with a URI pattern to search for controllers or components. In your case the class-path either has a jar having the previous version of your class or some referencing .class file in your build path.
Make sure you have your project cleaned up and if possible disconnect
from SVN and download the project again.
You could also try CTRL+SHIFT+T to see if your controller is
referenced from any other library.
I finally deleted my JBoss folder, removed the projects from JBoss in Eclipse, extract a proper JBoss, made a clean on JBoss in Eclipse and then redeployed my projects and it's now working.
Nonetheless it's a really strange issue...
Edit :
It was in fact because the build folder at the root of my project was versioned and the old classes were still present.
Now the folder is ignored and removed from the SVN and I've deleted the old classes from my FS.