asp.net no access to ConfigurationManager - linq-to-sql

I created one asp.net mvc application using linq to sql, and in the generated code it created this:
public ApowDataContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["APOWConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
Which worked well, However in my next mvc application for some reason it decided instead of looking at the web.config to look at a project resource instead... (and thus when deploying it did not work because the connectionstring was pointing to a dev server.
So to fix this I have edited the new projects datacontext to use the configurationmanager to grab the connectionstring BUT even after adding System.Configuration I cannot access the configuration manager (in my resources I can browse to the System.Configuration.ConfigurationManager and see the ConnectionStrings command, but in the code intellecence does not contain the ConfigurationManager under System.Configuration (but I can see a bunch of other methods, like ConfigurationSettings, for example)
So my questions are:
1\ Why has linq to sql objects decided to use a different method of looking up my connection string in my second project (i.e not use web.config).
2\ What is going on with the ConfigurationManager (why can't I access it?)

1&2\ The problem is that in my second solution, I have a separate project for the 'Model', and due to it not being in the .web project it does not by default look at the web.config, but in the project resources.
here is a good article how to sort this out: link text

Related

ActCtx + manifest + comhost + .NET 6.0: does it work, does anyone has a working example?

My goal is to expose a .NET 6.0 library to COM, in order to use it from VBA in MS Access. And to use the manifest approach rather than using the registry.
Got article "Exposing .NET Core components to COM" working, using their "COM server sample" example code.
This example however requires that a manifest file is present in the folder containing the executable. When using the COM object from MS Access we do not want to place the manifest file and other files in the MS installation folders.
The suggested solution is to create an Microsoft.Windows.ActCtx object and let that object create my COM object, using the Manifest property of the ActCtx object to specify the manifest file.
This is the part that continues to fail. actCtx.CreateObject("") gives an Invalid Cast exception, even without assignment of the result to a variable, hence it is an internal issue. No additional details, no information in the event log. Tried this in C# and from VBA.
I have a few questions:
Is ActCtx the way to specify the manifest path, or is there a better way to do this from VBA in MS Office?
The example uses a COM host, which seems to be some COM class / object factory, which in turn helps creating my COM object. As opposed to .NET Framework this COM host seems to be introduced for .NET Core; .NET 6.0 in my case. Is the COM host required? Is the simpler direct instantiation possible?
Does anyone has answers to these questions, tips, or even better: a working example?
Some progress but I am still not happy. Abandoned the ActCtx approach for a while and tried to create the COM server object of the sample directly in MS Access VBA. Added a reference to the com host, say COMServer.comhost.dll, as opposed to the implementation COMServer.dll. Created the object, simply with New. Error: class not registered. Performed a regsvr32 COMServer.comhost.dll and the sample works.
Although the sample works there are now again registry entries: the guid of the server class has been added to the registry. Regfree COM not achieved.
This is despite COMServer.comhost.dll looking promising. A tlb type library built separately and embedded in the .dll is seen by VBA: intellisense works and the object browser works. The manifest seems to be correctly embedded in the .dll too, and takes precedence over the manifest on disk.
The question remains how to avoid the regsvr32 step and make the solution working by just adding the reference to COMServer.comhost.dll, in MS Access VBA.

ABBYY Flexicapture connect to database

I have often run database queries in ABBYY Flexicapture by connecting to dll methods that contained the database calls. I would like to have the ability to connect directly in the ABBYY rules, if possible. A relatively recent update added the ability to write the rules in C#, so I'm assuming it's possible to do this.
I have added System.Data as a .Net Reference in the Document Definition properties, but I get "The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?" when I run this line of code:
SqlConn = new SqlConnection("[My Connection String]");
I have tried adding
using System.Data.SqlConnection
above that line and it says SqlConnection does not exist in System.Data.
Has anyone had success in doing this?
Try this:
using System.data.SqlClient

Create a shared datasource in VS2012 for SSRS

I'm just looking to create a shared datasource in VS2012 without selecting an entire database scheme. We'll mostly put doing all the dataset queries by sql query.
I found this but i'm still unable to create a shared datasource.
http://msdn.microsoft.com/en-us/library/ms159165.aspx
For an embedded data source, verify that Embedded connection is selected. Does not exists.
So how do you create a shared datasource in VS2012 with just a connection string?
A DataSource is just a connection string in an element in an xml structure as far as SSRS is concerned. A shared one is just one kept as it's own object and then the rdl elements(reports) have a reference in their xml to that object. Think of an rds file (data source for SSRS) as this very similar to .NET standard connection strings:
Data Source=(server);Initial Catalog=(database)
Plus you can store credentials to mock who is running the report. Thus you can make a proxy user to run the database connection. However SSRS does this through a GUI called 'Business Intelligence Development Studio' it is an add on to Visual Studio that is generally SQL Server version matches that VS version EXCEPT FOR 2012. That one creates a shell Visual Studio of VS 2010 just meant for BIDS.
To my knowledge you should be creating these directly in BIDS and not try to hack the RDS file directly unless you get the ReportService2010.asmx web service to mess with it's properties in .NET (which is a lot more work.).
To add one you just do this:
Go into BIDS with a report project
Expand a project
Right Click 'Shared Data Sources'> 'Add New'
Click 'Edit...' next to connection string
You get a menu very similar to ADO.NET standard connection string creator
Put in ServerName
Put in DatabaseName
8*** Optional put in default credentials.
Click OK
Generally SSRS has three parts to everything it does
Datasource = connection string (rds file when not embedded)
Dataset = select query or proc results or other data source return (rsd file when not embedded)
Report = resultant xml display of elements such as parameters, tables, matrices, etc. (RDL file when working on hosted report)
Generally reports can have everything embedded or else just reference everything they use. References are often easier for deployments sake as SSRS is designed to look if DataSources first exist and NOT OVERWRITE them by default. Thus if you reuse a datasource it is much easier in the long run as long as policy for it is set up correct.
If you want to just know the structure of an rds file they look like this:
<?xml version="1.0" encoding="utf-8"?>
<RptDataSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Test">
<ConnectionProperties>
<Extension>SQL</Extension>
<ConnectString>Data Source=TestServer;Initial Catalog=TestDatabase</ConnectString>
</ConnectionProperties>
<DataSourceID>45be0ac1-80a8-4d5c-906b-c13b03298e0a</DataSourceID>
</RptDataSource>

Strange issue when adding a service reference to a project that has the JSON.NET library referenced

The project is your standard run-of-the-mill ASP.NET MVC 3 application that communicates with an in house WCF service. Our ASP.NET MVC application references a few external libraries, including the popular JSON.NET library.
The issue only occurs when the JSON.NET library is a reference in a project. I tried recreating this issue with a WebForms and a Windows Forms project, and the same thing happens.
When adding a service reference to our WCF service, and JSON.NET is a reference in our project, it builds the service reference like this:
With JSON.NET referenced in the project - notice the Request/Response Classes and the weird properties like Id1 and IdSpecified
But removing the reference to JSON.NET and updating the service reference builds it the way we want, like this:
Without JSON.NET referenced in the project
...
What in the world would cause this? JSON.NET is not referenced in the WCF project, so I highly doubt that there could be some sort of mix up there.
Some information that may help:
Tried checking various options in the Add Service Reference dialog such as "Reuse types in referenced assemblies" - but the same thing happens
Visual Studio 2010
WCF service uses Entity Framework for data access
When you add a service reference, WCF by default will reuse the classes from your assemblies that match the ones that will be generated otherwise.
This happens because, for example, you might develop both the service and the client and you might want to have a class library with all the classes referenced in both projects. This also makes sure that .NET default types (like arrays, lists, DateTime) are used.
You can change this default behavior like this:
Click the Advanced button after you selected "Add service reference"
Select "Reuse types in specified referenced assemblies"
Check all the assemblies, except the ones that you don't want to
use
Note that if you don't check the system assemblies, you will get a new type generated in the proxy file for every .NET type (like arrays, lists) as well.

Error using Dynamic Data Filtering: missing datasource

I am trying to use the ASP.NET Dynamic Data Filtering project, but I'm running into a problem during the configuration.
I'm following the instructions on the author's blog, and everything works like described. Then it tells me to change the datasource using the designer view. I am told to select the "GridDataSource" in the "Configure data source" wizard. This option is not there though.
I get all of the classes in my project, including the DataContext that was generated by Linq. When I choose "Show only DataContext objects", the dropdown ("Choose your context object:") is completely empty.
When I turn of the checkbox and choose my DataContext class, I get asked which table I want and all that. But, as the whole purpose of a Dynamic Data site is NOT to use one single table, that's not much help.
So I've looked at the instructions again and copied the resulting datasource from the example:
<asp:DynamicLinqDataSource ID="GridDataSource" runat="server"
EnableDelete="True" EnableUpdate="True"></asp:DynamicLinqDataSource>
Which is exactly what I had, without the "WhereParameters" nodes in there.
Now, when I run the list page however, I get an exception about a missing datasource from the filtering component. Of course when I remove the DynamicFilterRepeater, it works again.
This is the meat of the exception:
[InvalidOperationException: Missing DataSource]
Catalyst.Web.DynamicData.DynamicFilterRepeater.GetTable() in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterRepeater.cs:74
Catalyst.Web.DynamicData.DynamicFilterRepeater.GetFilters() in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterRepeater.cs:81
Catalyst.Web.DynamicData.DynamicFilterRepeater.OnInit(EventArgs e) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterRepeater.cs:106
How do I make the DynamicFilterRepeater recognize my datasource?
I'm using VS2010 Pro, on a Win7 machine.
have you looked at the sample project you get when you download the source code.
Have a look at my blog post here Dynamic Data Filtering – Installation