DarthAffe / StableDiffusion.NET

C# Wrapper for StableDiffusion.cpp
MIT License
60 stars 11 forks source link

run error "System.DllNotFoundException:“Unable to load DLL 'stable-diffusion' or one of its dependencies: 找不到指定的模块。 (0x8007007E)”" #38

Open billqu01 opened 2 days ago

billqu01 commented 2 days ago

in my .net8 WinUI project. My codes: public MainWindow() { this.InitializeComponent();

// 获取当前应用的安装目录
string model_folder = Path.Combine(Package.Current.InstalledLocation.Path, "model");

// 构建完整的模型路径
var fluxPath = Path.Combine(model_folder, "flux1-schnell-q4_k.gguf");
var clipPath = Path.Combine(model_folder, "clip_l.safetensors");
var t5xxlPath = Path.Combine(model_folder, "t5xxl_fp8_e4m3fn.safetensors");
var aePath = Path.Combine(model_folder, "ae.safetensors");

// 初始化模型
model = ModelBuilder.Flux(fluxPath, clipPath, t5xxlPath, aePath)
                    .WithMultithreading()
                    .Build();

} in the line: model = ModelBuilder.Flux(fluxPath, clipPath, t5xxlPath, aePath) .WithMultithreading() .Build(); run error: Unable to load DLL 'stable-diffusion' or one of its dependencies: 找不到指定的模块。 (0x8007007E)

How to solve it?

Thank you.

DarthAffe commented 2 days ago

Assuming that you have installed one of the backend packages, I'd guess it's the same as https://github.com/DarthAffe/StableDiffusion.NET/issues/11 Some packaging issue that I can't really help with as it's a project specific thing.

billqu01 commented 2 days ago

I have installed StableDiffusion.NET.Backend.Cuda. But the error is still be in.

DarthAffe commented 1 day ago

Are you running your application in 32bit? Otherwise I'm pretty sure the dll is just not found which would be related to your project setup/publish/packing. You could try to call StableDiffusionCpp.LoadNativeLibrary at application start with the path to the stable-diffusion.dll