Could not load file or assembly System.Fabric with Azure Functions












1














Are there any restrictions with packages you can use with Azure Functions. I have researched as much as I can and it doesn't seem so, however when I try creating an Azure Function that references the package "Microsoft.ServiceFabric" I get the following error:




System.Private.CoreLib: Exception while executing function:
ScaleDownServiceFabrics. FunctionApp2: Could not load file or assembly
'System.Fabric, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific
file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib:
Could not load file or assembly 'System.Fabric, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.




I have tried both Azure Func and.1 and 2, and .Net Framework and .Net Core with no luck.



using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Fabric;

namespace FunctionApp5
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
FabricClient client = new FabricClient();
}
}
}


Is this possible, or a limitation of Azure Functions in Visual Studio - if so, what packages are acceptable?










share|improve this question




















  • 3




    ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
    – Diego Mendes
    Nov 13 '18 at 9:43










  • @tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
    – Suraj Revankar
    Nov 13 '18 at 10:06












  • @diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
    – tank104
    Nov 13 '18 at 22:09












  • @diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
    – tank104
    Nov 13 '18 at 22:11










  • @suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
    – tank104
    Nov 13 '18 at 22:13
















1














Are there any restrictions with packages you can use with Azure Functions. I have researched as much as I can and it doesn't seem so, however when I try creating an Azure Function that references the package "Microsoft.ServiceFabric" I get the following error:




System.Private.CoreLib: Exception while executing function:
ScaleDownServiceFabrics. FunctionApp2: Could not load file or assembly
'System.Fabric, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific
file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib:
Could not load file or assembly 'System.Fabric, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.




I have tried both Azure Func and.1 and 2, and .Net Framework and .Net Core with no luck.



using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Fabric;

namespace FunctionApp5
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
FabricClient client = new FabricClient();
}
}
}


Is this possible, or a limitation of Azure Functions in Visual Studio - if so, what packages are acceptable?










share|improve this question




















  • 3




    ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
    – Diego Mendes
    Nov 13 '18 at 9:43










  • @tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
    – Suraj Revankar
    Nov 13 '18 at 10:06












  • @diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
    – tank104
    Nov 13 '18 at 22:09












  • @diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
    – tank104
    Nov 13 '18 at 22:11










  • @suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
    – tank104
    Nov 13 '18 at 22:13














1












1








1







Are there any restrictions with packages you can use with Azure Functions. I have researched as much as I can and it doesn't seem so, however when I try creating an Azure Function that references the package "Microsoft.ServiceFabric" I get the following error:




System.Private.CoreLib: Exception while executing function:
ScaleDownServiceFabrics. FunctionApp2: Could not load file or assembly
'System.Fabric, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific
file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib:
Could not load file or assembly 'System.Fabric, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.




I have tried both Azure Func and.1 and 2, and .Net Framework and .Net Core with no luck.



using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Fabric;

namespace FunctionApp5
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
FabricClient client = new FabricClient();
}
}
}


Is this possible, or a limitation of Azure Functions in Visual Studio - if so, what packages are acceptable?










share|improve this question















Are there any restrictions with packages you can use with Azure Functions. I have researched as much as I can and it doesn't seem so, however when I try creating an Azure Function that references the package "Microsoft.ServiceFabric" I get the following error:




System.Private.CoreLib: Exception while executing function:
ScaleDownServiceFabrics. FunctionApp2: Could not load file or assembly
'System.Fabric, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific
file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib:
Could not load file or assembly 'System.Fabric, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.




I have tried both Azure Func and.1 and 2, and .Net Framework and .Net Core with no luck.



using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Fabric;

namespace FunctionApp5
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
FabricClient client = new FabricClient();
}
}
}


Is this possible, or a limitation of Azure Functions in Visual Studio - if so, what packages are acceptable?







c# azure azure-functions azure-service-fabric azure-functions-core-tools






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 22:23







tank104

















asked Nov 13 '18 at 8:41









tank104tank104

7719




7719








  • 3




    ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
    – Diego Mendes
    Nov 13 '18 at 9:43










  • @tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
    – Suraj Revankar
    Nov 13 '18 at 10:06












  • @diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
    – tank104
    Nov 13 '18 at 22:09












  • @diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
    – tank104
    Nov 13 '18 at 22:11










  • @suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
    – tank104
    Nov 13 '18 at 22:13














  • 3




    ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
    – Diego Mendes
    Nov 13 '18 at 9:43










  • @tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
    – Suraj Revankar
    Nov 13 '18 at 10:06












  • @diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
    – tank104
    Nov 13 '18 at 22:09












  • @diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
    – tank104
    Nov 13 '18 at 22:11










  • @suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
    – tank104
    Nov 13 '18 at 22:13








3




3




ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
– Diego Mendes
Nov 13 '18 at 9:43




ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Can you check that? Another point is, you have to add the dependencies as packages instead of reference the dll directly in the project, because of the dependencies on other libraries.
– Diego Mendes
Nov 13 '18 at 9:43












@tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
– Suraj Revankar
Nov 13 '18 at 10:06






@tank: Diego has provided good checklist for the errors, also can you build the solution with the same and see if you get any errors on error list window, and also make sure to check the solution has all the packages(if using nuget just try to update the packages) and any other referencing dll's , and then test once.
– Suraj Revankar
Nov 13 '18 at 10:06














@diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
– tank104
Nov 13 '18 at 22:09






@diego - I tried changing to x64 (the default with new Azure Function in VS is Any CPU). But got this error: [13/11/2018 10:08:38 PM] A host error has occurred. [13/11/2018 10:08:38 PM] System.Private.CoreLib: Could not load file or assembly 'FunctionApp5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.I don't think this is related.
– tank104
Nov 13 '18 at 22:09














@diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
– tank104
Nov 13 '18 at 22:11




@diego - I definitely referenced as a package not DLL. Package is "Microsoft.ServiceFabric". I updated the above code to the simplest possible way to replciate the issue.
– tank104
Nov 13 '18 at 22:11












@suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
– tank104
Nov 13 '18 at 22:13




@suraj - I am not sure what you mean by "build the solution with the same". Do you mean in x64? If so that causes issues above. All referencing DLLs are in the bin. Only thing I noticed was that System.Fabric.Dll has File Version 6.0.0.0 but product version 6.3.187.9494 - although I think this counts as 6.0.0.0
– tank104
Nov 13 '18 at 22:13












2 Answers
2






active

oldest

votes


















2















  • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu

  • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.


  • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.

  • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when builtdeployed.

  • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.

  • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts






share|improve this answer





















  • Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
    – tank104
    Nov 14 '18 at 19:56












  • I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
    – Diego Mendes
    Nov 14 '18 at 21:36










  • one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
    – tank104
    Nov 15 '18 at 2:12










  • NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
    – tank104
    Nov 15 '18 at 2:15










  • I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
    – tank104
    Nov 15 '18 at 2:23



















2














Diego and Suraj have pointed out the cause, conflict between 64 and 32 bit.



Two points to fix




  1. Set build platform to x64 like what you have done.

  2. Get x64 Function runtime. Functions work on Function runtime(contained in Azure Function core tools), but the default bit is x86 downloaded by VS.


To get x64 bit in an easy way, let's use Nodejs to install Azure Functions Core Tools from NPM.



After installation, in cmd input npm i -g azure-functions-core-tools --unsafe-perm true to get Function core tools.



Then set project debug properties(right click on your project>Properties>Debug blade).




  1. Set Launch type to Executable


  2. Set Executable path to %appdata%npmnode_modulesazure-functions-core-toolsbinfunc.exe.


  3. Add Application arguments start.







share|improve this answer





















  • Thanks Jerry - your guide to run in 64-bit sorted it.
    – tank104
    Nov 14 '18 at 19:57











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276947%2fcould-not-load-file-or-assembly-system-fabric-with-azure-functions%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2















  • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu

  • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.


  • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.

  • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when builtdeployed.

  • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.

  • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts






share|improve this answer





















  • Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
    – tank104
    Nov 14 '18 at 19:56












  • I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
    – Diego Mendes
    Nov 14 '18 at 21:36










  • one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
    – tank104
    Nov 15 '18 at 2:12










  • NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
    – tank104
    Nov 15 '18 at 2:15










  • I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
    – tank104
    Nov 15 '18 at 2:23
















2















  • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu

  • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.


  • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.

  • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when builtdeployed.

  • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.

  • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts






share|improve this answer





















  • Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
    – tank104
    Nov 14 '18 at 19:56












  • I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
    – Diego Mendes
    Nov 14 '18 at 21:36










  • one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
    – tank104
    Nov 15 '18 at 2:12










  • NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
    – tank104
    Nov 15 '18 at 2:15










  • I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
    – tank104
    Nov 15 '18 at 2:23














2












2








2







  • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu

  • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.


  • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.

  • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when builtdeployed.

  • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.

  • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts






share|improve this answer













  • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu

  • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.


  • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.

  • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when builtdeployed.

  • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.

  • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 10:19









Diego MendesDiego Mendes

4,28211826




4,28211826












  • Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
    – tank104
    Nov 14 '18 at 19:56












  • I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
    – Diego Mendes
    Nov 14 '18 at 21:36










  • one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
    – tank104
    Nov 15 '18 at 2:12










  • NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
    – tank104
    Nov 15 '18 at 2:15










  • I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
    – tank104
    Nov 15 '18 at 2:23


















  • Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
    – tank104
    Nov 14 '18 at 19:56












  • I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
    – Diego Mendes
    Nov 14 '18 at 21:36










  • one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
    – tank104
    Nov 15 '18 at 2:12










  • NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
    – tank104
    Nov 15 '18 at 2:15










  • I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
    – tank104
    Nov 15 '18 at 2:23
















Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
– tank104
Nov 14 '18 at 19:56






Hi Diego, many thanks for that - it was the issue! Is there an easy way to tell if a package is 64 bit only?
– tank104
Nov 14 '18 at 19:56














I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
– Diego Mendes
Nov 14 '18 at 21:36




I knew it because I suffered a lot with this Library and is the first check I do. There are many ways, I generally use ILSpy, but you can find many alternatives here: stackoverflow.com/questions/270531/…
– Diego Mendes
Nov 14 '18 at 21:36












one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
– tank104
Nov 15 '18 at 2:12




one other question - when I build and deploy this in VSTS - I get this error in Azure Function App: Function (FeedExports) Error: Unable to load one or more of the requested types. Could not load file or assembly 'System.Fabric, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). I have downloaded the file contents from the Azure Function App and the DLL is there. Any ideas?
– tank104
Nov 15 '18 at 2:12












NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
– tank104
Nov 15 '18 at 2:15




NEeded to change the Azure function app from 32-bit to 64-bit sorted it.
– tank104
Nov 15 '18 at 2:15












I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
– tank104
Nov 15 '18 at 2:23




I am getting this now in the logs: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E) I guess as the client is not installed on the App Service. If you got it working - did you just add this DLL to deployment?
– tank104
Nov 15 '18 at 2:23













2














Diego and Suraj have pointed out the cause, conflict between 64 and 32 bit.



Two points to fix




  1. Set build platform to x64 like what you have done.

  2. Get x64 Function runtime. Functions work on Function runtime(contained in Azure Function core tools), but the default bit is x86 downloaded by VS.


To get x64 bit in an easy way, let's use Nodejs to install Azure Functions Core Tools from NPM.



After installation, in cmd input npm i -g azure-functions-core-tools --unsafe-perm true to get Function core tools.



Then set project debug properties(right click on your project>Properties>Debug blade).




  1. Set Launch type to Executable


  2. Set Executable path to %appdata%npmnode_modulesazure-functions-core-toolsbinfunc.exe.


  3. Add Application arguments start.







share|improve this answer





















  • Thanks Jerry - your guide to run in 64-bit sorted it.
    – tank104
    Nov 14 '18 at 19:57
















2














Diego and Suraj have pointed out the cause, conflict between 64 and 32 bit.



Two points to fix




  1. Set build platform to x64 like what you have done.

  2. Get x64 Function runtime. Functions work on Function runtime(contained in Azure Function core tools), but the default bit is x86 downloaded by VS.


To get x64 bit in an easy way, let's use Nodejs to install Azure Functions Core Tools from NPM.



After installation, in cmd input npm i -g azure-functions-core-tools --unsafe-perm true to get Function core tools.



Then set project debug properties(right click on your project>Properties>Debug blade).




  1. Set Launch type to Executable


  2. Set Executable path to %appdata%npmnode_modulesazure-functions-core-toolsbinfunc.exe.


  3. Add Application arguments start.







share|improve this answer





















  • Thanks Jerry - your guide to run in 64-bit sorted it.
    – tank104
    Nov 14 '18 at 19:57














2












2








2






Diego and Suraj have pointed out the cause, conflict between 64 and 32 bit.



Two points to fix




  1. Set build platform to x64 like what you have done.

  2. Get x64 Function runtime. Functions work on Function runtime(contained in Azure Function core tools), but the default bit is x86 downloaded by VS.


To get x64 bit in an easy way, let's use Nodejs to install Azure Functions Core Tools from NPM.



After installation, in cmd input npm i -g azure-functions-core-tools --unsafe-perm true to get Function core tools.



Then set project debug properties(right click on your project>Properties>Debug blade).




  1. Set Launch type to Executable


  2. Set Executable path to %appdata%npmnode_modulesazure-functions-core-toolsbinfunc.exe.


  3. Add Application arguments start.







share|improve this answer












Diego and Suraj have pointed out the cause, conflict between 64 and 32 bit.



Two points to fix




  1. Set build platform to x64 like what you have done.

  2. Get x64 Function runtime. Functions work on Function runtime(contained in Azure Function core tools), but the default bit is x86 downloaded by VS.


To get x64 bit in an easy way, let's use Nodejs to install Azure Functions Core Tools from NPM.



After installation, in cmd input npm i -g azure-functions-core-tools --unsafe-perm true to get Function core tools.



Then set project debug properties(right click on your project>Properties>Debug blade).




  1. Set Launch type to Executable


  2. Set Executable path to %appdata%npmnode_modulesazure-functions-core-toolsbinfunc.exe.


  3. Add Application arguments start.








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 7:59









Jerry LiuJerry Liu

9,5331628




9,5331628












  • Thanks Jerry - your guide to run in 64-bit sorted it.
    – tank104
    Nov 14 '18 at 19:57


















  • Thanks Jerry - your guide to run in 64-bit sorted it.
    – tank104
    Nov 14 '18 at 19:57
















Thanks Jerry - your guide to run in 64-bit sorted it.
– tank104
Nov 14 '18 at 19:57




Thanks Jerry - your guide to run in 64-bit sorted it.
– tank104
Nov 14 '18 at 19:57


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276947%2fcould-not-load-file-or-assembly-system-fabric-with-azure-functions%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python