Kinetic LinqPad Starter

I used to use the following to connect to E10, but since switching to Kinetic, this no longer works and I get the error about not finding System.Transactions.Local

Does anyone have a way to connect using LinqPad?

// f4 - added EntityFramework.SqlServer.dll (SERVER/ASSEMBLIES)
void Main()
{
	// Change query references to point to the correct Ice.Data.Model.dll and Erp.Data.910100.dll from your server directories (Press F4 or Edit the .linq file).	
	// Change this to point to your server web.config file
	var webConfigFile = @"\\xxx\E10Web\xxxApp\Server\web.config";
	
	InitialiseConfiguration(webConfigFile);
	//
	// Enable for 10.2 Only
	EpiProviderRegistrator.Register();
	//
	var Db = new ErpContext();
	Db.Part.Where(p=>p.Company == "xxx" && p.TrackLots == true).Dump();
}

private void InitialiseConfiguration(string webConfigPath)
{
	// Resetting is based on http://stackoverflow.com/questions/6150644/change-default-app-config-at-runtime
	AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", webConfigPath);
	typeof(ConfigurationManager)
	                .GetField("s_initState", BindingFlags.NonPublic | 
	                                         BindingFlags.Static)
	                .SetValue(null, 0);
	
	            typeof(ConfigurationManager)
	                .GetField("s_configSystem", BindingFlags.NonPublic | 
	                                            BindingFlags.Static)
	                .SetValue(null, null);
	
	            typeof(ConfigurationManager)
	                .Assembly.GetTypes()
	                .Where(x => x.FullName == 
	                            "System.Configuration.ClientConfigPaths")
	                .First()
	                .GetField("s_current", BindingFlags.NonPublic | 
	                                       BindingFlags.Static)
	                .SetValue(null, null);
	
	//ConfigurationManager.ConnectionStrings.Dump();
}


and additional namespace imports
image

This is the additional references

We’ve had similar issues when trying to do local development of BPMs.

First step is to install .NET 6 SDK, and see if that fixes it.

I installed .net sdk 6.0.406, rebooted and it’s still not working:
image

I’m not familiar with LinqPad, but if you are able to add references, add

“System.Transactions.Local.dll”

I’ve added System.Transactions.Local and still get this error:

That one is in “System.Runtime.dll”

Microsoft redirecting things seems to be causing unintended side effects, but most of the time
it just works. It’s not consistent!

I have System.Runtime.dll in there. If anyone know what references I need for Kinetic in linqpad … that’s what is needed. I am missing something. Thanks!

You aren’t missing something, you are working around a problem :slight_smile:

It’s trying to pull v4.0.0.0 of the runtime which is not .NET 6.

Do you know how I get Erp.ErpContext… to look at 6 framework?

There is no .NET 6 Framework, just .NET 6 (previously core), last and final framework was 4.8.

You may not need to point to .NET 6, do you have any 4.x .NET FW installed? If not, install 4.8.

There is some mixtures in Epicor I have not been able to figure out quite yet.

No, entity framework is. net standard 2.1, that requires. Net 6

I just now seen this picture. All the .NET references you show there are
.NET Framework 4, not .NET 6.

Try referencing the 6 versions, and if you don’t need it all, pair it down to the
bare minimum for troubleshooting.

I switched them all to .net 6, still getting errors.

here is a screen shot of the errors:

i did not try .NET 6 server with linqpad, but just from looking on the screen I can tell, that you will have to rewrite this.
easy part - settings are now in host.config, not web.config
.NET (Core) does not use AppDomain at all.

Also Configuration manager was changed beween .NET Framework and .NET Core.

So probably it would be easier to start from scratch - create new .NET project and try to use ERP DataModel first, then add additional code you need.

(also, just in case, it should be linqpad 7 Using LINQPad with Entity Framework )

2 Likes

Did you ever get this working @maverick ?

I did not.

Bummer - but thanks for letting me know.

I started a new thread to see if anyone has figured this out, but so far pretty quiet.