Skip to content

Commit e78bc40

Browse files
committed
Fixed 'Tx.LinqPad.resources' issue
1 parent f37a827 commit e78bc40

File tree

8 files changed

+112
-31
lines changed

8 files changed

+112
-31
lines changed

References/LinqPad/LINQPad.exe

12.3 MB
Binary file not shown.
Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup useLegacyV2RuntimeActivationPolicy="true">
4-
<supportedRuntime version="v4.0"/>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
55
</startup>
66
<runtime>
77
<legacyUnhandledExceptionPolicy enabled="1" />
8+
<loadFromRemoteSources enabled="true" />
9+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
10+
<dependentAssembly>
11+
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
12+
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
13+
</dependentAssembly>
14+
<dependentAssembly>
15+
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
16+
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
17+
</dependentAssembly>
18+
<dependentAssembly>
19+
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
20+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
21+
</dependentAssembly>
22+
<dependentAssembly>
23+
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
24+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
25+
</dependentAssembly>
26+
<dependentAssembly>
27+
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
28+
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
29+
</dependentAssembly>
30+
<dependentAssembly>
31+
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
32+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
33+
</dependentAssembly>
34+
<dependentAssembly>
35+
<assemblyIdentity name="System.Diagnostics.FileVersionInfo" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
36+
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
37+
</dependentAssembly>
38+
<dependentAssembly>
39+
<assemblyIdentity name="System.Threading.Thread" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
40+
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
41+
</dependentAssembly>
42+
<probing privatePath="ngen003" />
43+
</assemblyBinding>
844
</runtime>
45+
<appSettings>
46+
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
47+
</appSettings>
948
</configuration>

Source/Build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pushd
4747
cd /d %sourceFolder%Tx.Linqpad || goto failFast
4848
dotnet restore || goto failFast
4949
%msbuildPath% /p:Configuration=Release || goto failFast
50-
cd /d %sourceFolder%Tx.Linqpad\bin\Release\net45 || goto failFast
50+
cd /d %sourceFolder%Tx.Linqpad\bin\Release\net46 || goto failFast
5151
%sourceFolder%..\tools\zip.exe %dropFolder%Tx.LinqPad.lpx header.xml System.Reactive.Interfaces.dll System.Reactive.Core.dll System.Reactive.Linq.dll System.Reactive.PlatformServices.dll System.Reactive.Windows.Forms.dll Tx.Core.dll Tx.Windows.dll Tx.Windows.TypeGeneration.dll Tx.SqlServer.dll %sourceFolder%..\References\XEvent\msvcr100.dll %sourceFolder%..\References\XEvent\xe.dll Microsoft.SqlServer.XE.Core.dll Microsoft.SqlServer.XEvent.Configuration.dll Microsoft.SqlServer.XEvent.dll Microsoft.SqlServer.XEvent.Linq.dll Microsoft.SqlServer.XEvent.Targets.dll Tx.LinqPad.dll HTTP_Server.man HTTP_Server.etl BasicPerfCounters.blg CrossMachineHTTP.etl CrossMachineIE.etl IE_Client.man sqltrace.xel Microsoft.Windows.ApplicationServer.Applications.man SampleWcfTrace.etl || goto failFast
5252
popd
5353

Source/Tx.LinqPad/ParserRegistry.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
22

3+
using LINQPad.Extensibility.DataContext;
34
using Microsoft.SqlServer.XEvent;
45
using System;
56
using System.Collections.Generic;
@@ -21,7 +22,7 @@ public ParserRegistry()
2122
string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
2223

2324
IEnumerable<Type> types = from file in Directory.GetFiles(dir, "Tx*.dll")
24-
from t in Assembly.LoadFrom(file).GetTypes()
25+
from t in DataContextDriver.LoadAssemblySafely(file).GetTypes()
2526
where t.IsPublic
2627
select t;
2728

Source/Tx.LinqPad/Tx.LinqPad.csproj

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>net45</TargetFramework>
4+
<TargetFramework>net46</TargetFramework>
55
<SignAssembly>True</SignAssembly>
66
<AssemblyOriginatorKeyFile>..\key.snk</AssemblyOriginatorKeyFile>
7+
<Version>2.1.1</Version>
78
</PropertyGroup>
8-
99
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
1010
<PlatformTarget>x86</PlatformTarget>
1111
</PropertyGroup>
12-
1312
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1413
<PlatformTarget>x86</PlatformTarget>
1514
</PropertyGroup>
16-
1715
<ItemGroup>
18-
<Compile Remove="ConnectionDialog.xaml.cs">
19-
</Compile>
16+
<Compile Remove="ConnectionDialog.xaml.cs"></Compile>
2017
<Compile Include="ConnectionDialog.xaml.cs">
2118
<DependentUpon>ConnectionDialog.xaml</DependentUpon>
2219
</Compile>
@@ -25,15 +22,13 @@
2522
<SubType>Designer</SubType>
2623
</Page>
2724
</ItemGroup>
28-
2925
<ItemGroup>
3026
<PackageReference Include="System.Reactive" Version="3.0.0" />
3127
<ProjectReference Include="..\Tx.Core\Tx.Core.csproj" />
3228
<ProjectReference Include="..\Tx.SqlServer\Tx.SqlServer.csproj" />
3329
<ProjectReference Include="..\Tx.Windows.TypeGeneration\Tx.Windows.TypeGeneration.csproj" />
3430
<ProjectReference Include="..\Tx.Windows\Tx.Windows.csproj" />
3531
</ItemGroup>
36-
3732
<ItemGroup>
3833
<Reference Include="LINQPad">
3934
<HintPath>..\..\References\LinqPad\LINQPad.exe</HintPath>
@@ -50,7 +45,6 @@
5045
<Reference Include="Microsoft.SqlServer.XEvent.Targets">
5146
<HintPath>..\..\References\XEvent\Microsoft.SqlServer.XEvent.Targets.dll</HintPath>
5247
</Reference>
53-
5448
<Reference Include="PresentationCore" />
5549
<Reference Include="PresentationFramework" />
5650
<Reference Include="System" />
@@ -66,13 +60,11 @@
6660
<Reference Include="System.Xml" />
6761
<Reference Include="WindowsBase" />
6862
</ItemGroup>
69-
7063
<ItemGroup>
7164
<None Update="header.xml">
7265
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7366
</None>
7467
</ItemGroup>
75-
7668
<ItemGroup>
7769
<None Include="..\..\Traces\HTTP_Server.etl">
7870
<Link>HTTP_Server.etl</Link>
@@ -111,5 +103,4 @@
111103
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
112104
</None>
113105
</ItemGroup>
114-
115106
</Project>

Source/Tx.LinqPad/TxDataContextDriver.cs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,19 @@ public override string GetConnectionDescription(IConnectionInfo cxInfo)
133133

134134
public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
135135
{
136-
var properties = new TxProperties(cxInfo);
137-
return new ConnectionDialog(properties, _parserRegistry.Filter).ShowDialog() ?? false;
136+
try
137+
{
138+
var properties = new TxProperties(cxInfo);
139+
return new ConnectionDialog(properties, _parserRegistry.Filter).ShowDialog() ?? false;
140+
}
141+
catch (Exception error)
142+
{
143+
TxEventSource.Log.TraceError(error.ToString());
144+
145+
MessageBox.Show(error.ToString(), "ShowConnectionDialog");
146+
147+
return false;
148+
}
138149
}
139150

140151
public override ParameterDescriptor[] GetContextConstructorParameters(IConnectionInfo cxInfo)
@@ -301,19 +312,26 @@ public override void OnQueryFinishing(IConnectionInfo cxInfo, object context, Qu
301312

302313
private static Assembly AssemblyResolve(object sender, ResolveEventArgs args)
303314
{
304-
string assemblyname = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
305-
string driverDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
306-
IEnumerable<string> assemblies = Directory.EnumerateFiles(driverDir, assemblyname);
307-
foreach (string path in assemblies)
315+
try
308316
{
309-
return Assembly.LoadFrom(path);
310-
}
317+
string assemblyname = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";
318+
string driverDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
319+
IEnumerable<string> assemblies = Directory.EnumerateFiles(driverDir, assemblyname);
320+
foreach (string path in assemblies)
321+
{
322+
return DataContextDriver.LoadAssemblySafely(path);
323+
}
311324

312-
string root = Path.Combine(Path.GetTempPath(), @"LINQPad\");
313-
assemblies = Directory.EnumerateFiles(root, assemblyname, SearchOption.AllDirectories);
314-
foreach (string path in assemblies)
325+
string root = Path.Combine(Path.GetTempPath(), @"LINQPad\");
326+
assemblies = Directory.EnumerateFiles(root, assemblyname, SearchOption.AllDirectories);
327+
foreach (string path in assemblies)
328+
{
329+
return DataContextDriver.LoadAssemblySafely(path);
330+
}
331+
}
332+
catch (Exception error)
315333
{
316-
return Assembly.LoadFrom(path);
334+
TxEventSource.Log.TraceError(error.ToString());
317335
}
318336

319337
return null;

Source/Tx.LinqPad/TxEventSource.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Diagnostics.Tracing;
2+
using System.Runtime.CompilerServices;
3+
4+
namespace Tx.LinqPad
5+
{
6+
[EventSource(Name = "Microsoft-Tx-LinqpadDriver")]
7+
public sealed class TxEventSource : EventSource
8+
{
9+
public static readonly TxEventSource Log = new TxEventSource();
10+
11+
public class Keywords
12+
{
13+
public const EventKeywords Debug = ((EventKeywords)(1));
14+
15+
public const EventKeywords Perf = ((EventKeywords)(2));
16+
17+
public const EventKeywords Telemetry = ((EventKeywords)(4));
18+
19+
public const EventKeywords Auditing = ((EventKeywords)(8));
20+
}
21+
22+
[Event(1, Level = EventLevel.Error, Keywords = Keywords.Debug, Message = "File: {0} Method: {1}, Exception: {2}")]
23+
public void TraceError(string exception, [CallerFilePath] string fileName = null, [CallerMemberName] string methodName = null)
24+
{
25+
if (this.IsEnabled())
26+
{
27+
this.WriteEvent(1, fileName, methodName, exception);
28+
}
29+
}
30+
}
31+
}

Source/Tx.LinqPad/TypeCache.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
22

3+
using LINQPad.Extensibility.DataContext;
34
using Microsoft.SqlServer.XEvent;
45
using System;
56
using System.Collections.Generic;
@@ -147,7 +148,7 @@ public string[] GetAssemblies(string targetDir, string[] traces, string[] metada
147148
public Type[] GetAvailableTypes(string targetDir, string[] traces, string[] metadaFiles)
148149
{
149150
Assembly[] assemblies = (from file in GetAssemblies(targetDir, traces, metadaFiles)
150-
select Assembly.LoadFrom(file)).ToArray();
151+
select DataContextDriver.LoadAssemblySafely(file)).ToArray();
151152

152153
var types = (from a in assemblies
153154
from t in a.GetTypes()

0 commit comments

Comments
 (0)