Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Stateful service referencing .net standard library #662

Closed
stachen opened this issue Nov 20, 2017 · 9 comments
Closed

Stateful service referencing .net standard library #662

stachen opened this issue Nov 20, 2017 · 9 comments

Comments

@stachen
Copy link

stachen commented Nov 20, 2017

Hi,

I'm trying to reference .net standard library from a stateful service, and I ran into a few problems

  1. When the stateful service is .net core 2.0 and the .net standard library references Microsoft.ServiceFabric.Data 3.0.232-preview. I get the following error from this line

     public DotNetCoreApp(StatefulServiceContext context)
         : base(context)
     { }
    

System.TypeLoadException: 'Type 'Microsoft.ServiceFabric.Data.ReliableStateManagerImpl' from assembly 'Microsoft.ServiceFabric.Data.Impl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.'

However, it works when the .net standard library is using Microsoft.ServiceFabric.Data 3.0.232-preview

  1. When the stateful service is .Net 461 and .net standard library references Microsoft.ServiceFabric.Data 3.0.219-preview, I get this
Exception in OpenAsync.  Type: System.IO.FileNotFoundException Message: Could not load file or assembly 'file:///C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code\NS\System.IO.FileSystem.AccessControl.dll' or one of its dependencies. The system cannot find the file specified. HResult: 0x80070002. Stack Trace:    at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
       at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
       at System.Reflection.RuntimeMethodInfo.GetParameters()
       at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
       at System.Exception.GetStackTrace(Boolean needFileInfo)
       at Microsoft.ServiceFabric.Replicator.KtlLogManager.<CreateLogFileAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceFabric.Replicator.LogManager.<OpenAsync>d__81.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceFabric.Replicator.LoggingReplicator.<OpenAsync>d__141.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceFabric.Replicator.LoggingReplicator.<OpenAsync>d__140.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.ServiceFabric.Replicator.DynamicStateManager.<OpenAsync>d__110.MoveNext(). ",
@mkosieradzki
Copy link

  1. This one you get if you don't upgrade your SF runtime to 6.0.232 (you are probably running 6.0.219).
  2. This is a duplicate to Could not load file or assembly 'System.IO.FileSystem.AccessControl' after upgrading to .NET Core 2.0 #639

@hrushib
Copy link
Member

hrushib commented Nov 22, 2017

For issue 1, it looks like you did setup cluster using 2.8.219 SDK. Please download latest SDK (2.8.232) and then deploy your App to cluster created post 2.8.232 SDK installation.

For issue 2, as @mkosieradzki already mentioned, this is duplicate of #639 and we are working on the fix.

@ravipal
Copy link

ravipal commented Jan 29, 2018

The latest nuget package (1.6.4) has the fix. Please add the property <PackageOutputFolder>true</PackageOutputFolder> to *.sfproj to change the package behavior that will include all the files from output folder.

@ravipal ravipal closed this as completed Jan 29, 2018
@dbreshears
Copy link
Member

@geedsen, what version of VS 2017 from help about? Ensure you have 15.5.6 or 15.6 Preview 4. In Tools->Extensions and updates you should see 2.0.20180124.2 for the "Service Fabric Tools" extension version. Also, whatSDK version do you have of Service Fabric? I would ensure you have the latest 3.0.456 SDK version. After verifying these, you will need to open the .sfproj file and add true, then reload the solution as @ravipal points out. It looks like you have verified already in .sfproj or package.config that Microsoft.VisualStudio.Azure.Fabric.MSBuild = 1.6.4.

@geedsen
Copy link

geedsen commented Feb 9, 2018

VS and Tools are the same versions as you mention. SDK I was not sure so I installed the version 3.0.456.
Problem remains when I deploy to Azure. Works fine btw when deploying to the local cluster. When Deploying to Azure, the code.zip file does not contain the netstandard.dll.

@ravipal
Copy link

ravipal commented Feb 9, 2018

@geedsen, Can you please share your service project file?

@geedsen
Copy link

geedsen commented Feb 9, 2018

@ravipal
Copy link

ravipal commented Feb 9, 2018

@geedsen your web project is targeting .NET Framework 4.7.1 which includes the netstandard assemblies so the web project package skips packaging this dll.
<TargetFramework>net471</TargetFramework>

Please note that the <PackageOutputFolder>true</PackageOutputFolder> will be used only for non-web projects that is targeting fullframework.

Either you should change the target framework to 4.6.1 or make sure the cluster node is installed with .NET framework 4.7.1

@geedsen
Copy link

geedsen commented Feb 9, 2018

Thanks! I'll will just do one of the two.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants