Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
3560a439
Commit
3560a439
authored
9 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
correct handling for shadowed assemblies when loading native extension
parent
921f4b0a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/csharp/Grpc.Core/Internal/NativeExtension.cs
+20
-3
20 additions, 3 deletions
src/csharp/Grpc.Core/Internal/NativeExtension.cs
with
20 additions
and
3 deletions
src/csharp/Grpc.Core/Internal/NativeExtension.cs
+
20
−
3
View file @
3560a439
...
...
@@ -32,6 +32,7 @@
#endregion
using
System
;
using
System.Globalization
;
using
System.IO
;
using
System.Reflection
;
...
...
@@ -99,14 +100,30 @@ namespace Grpc.Core.Internal
// TODO: allow customizing path to native extension (possibly through exposing a GrpcEnvironment property).
var
libraryFlavor
=
string
.
Format
(
"{0}_{1}"
,
GetPlatformString
(),
GetArchitectureString
());
var
fullPath
=
Path
.
Combine
(
GetExecutingAssemblyDirectory
(
),
var
fullPath
=
Path
.
Combine
(
Path
.
GetDirectoryName
(
GetAssemblyPath
()
),
NativeLibrariesDir
,
libraryFlavor
,
GetNativeLibraryFilename
());
return
new
UnmanagedLibrary
(
fullPath
);
}
private
static
string
Get
ExecutingAssemblyDirectory
()
private
static
string
Get
AssemblyPath
()
{
return
Path
.
GetDirectoryName
(
typeof
(
NativeExtension
).
GetTypeInfo
().
Assembly
.
Location
);
var
assembly
=
typeof
(
NativeExtension
).
GetTypeInfo
().
Assembly
;
// If assembly is shadowed (e.g. in a webapp), EscapedCodeBase is pointing
// to the original location of the assembly, and Location is pointing
// to the shadow copy. We care about the original location because
// the native dlls don't get shadowed.
var
escapedCodeBase
=
assembly
.
EscapedCodeBase
;
if
(
IsFileUri
(
escapedCodeBase
))
{
return
new
Uri
(
escapedCodeBase
).
LocalPath
;
}
return
assembly
.
Location
;
}
private
static
bool
IsFileUri
(
string
uri
)
{
return
uri
.
ToLowerInvariant
().
StartsWith
(
Uri
.
UriSchemeFile
);
}
private
static
string
GetPlatformString
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment