Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abnormal operation of DEMO program #152

Open
snikeguo opened this issue Apr 12, 2023 · 1 comment
Open

Abnormal operation of DEMO program #152

snikeguo opened this issue Apr 12, 2023 · 1 comment
Assignees
Labels

Comments

@snikeguo
Copy link

OS:win10

public static void Main(string[] args) 
        {
            var services = new ServiceCollection();

            // use %TEMP%/TestFtpServer as root folder
            /*services.Configure<DotNetFileSystemOptions>(opt => opt
                .RootPath = Directory.GetCurrentDirectory());*/

            // Add FTP server services
            // DotNetFileSystemProvider = Use the .NET file system functionality
            // AnonymousMembershipProvider = allow only anonymous logins
            services.AddFtpServer(builder => builder
                .UseUnixFileSystem() // Use the .NET file system functionality
                .EnableAnonymousAuthentication()); // allow anonymous logins

            // Configure the FTP server
            services.Configure<FtpServerOptions>(opt => opt.ServerAddress = "127.0.0.1");

            // Build the service provider
            using (var serviceProvider = services.BuildServiceProvider())
            {
                // Initialize the FTP server
                var ftpServerHost = serviceProvider.GetRequiredService<IFtpServerHost>();

                // Start the FTP server
                ftpServerHost.StartAsync(CancellationToken.None).Wait();

                Console.WriteLine("Press ENTER/RETURN to close the test application.");
                Console.ReadLine();

                // Stop the FTP server
                ftpServerHost.StopAsync(CancellationToken.None).Wait();
            }
           
        }

run result:

System.InvalidOperationException:“Unable to resolve service for type 'Microsoft.Extensions.Logging.ILoggerFactory' while attempting to activate 'FubarDev.FtpServer.FileSystem.Unix.UnixFileSystemProvider'.”

After modifying the UseDotNetFileSystem method to the UseUnixFileSystem method, I received an error message.

I developed a device that is not a Udisk but a custom USB device. Then I developed the c#library, which provides interfaces such as mkdir, open, write, close, etc. The library has a file system catalog style of UNIX (e.g. /home/test), and I want to modify the code of FubarDev.FtpServer.FileSystem.Unix:

Eg:

Public Task UnlinkAsync (IUnixFileSystemEntry entry, CancellationToken cancellationToken)
{
FatFsFuseLib.Unlink(....);
}
@fubar-coder
Copy link
Contributor

fubar-coder commented Apr 12, 2023

You've found a bug 👍

The line ILoggerFactory? loggerFactory should read ILoggerFactory? loggerFactory = null.

You can also add logging to your app (https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.loggingservicecollectionextensions.addlogging?view=dotnet-plat-ext-7.0&viewFallbackFrom=net-6.0).

@fubar-coder fubar-coder self-assigned this Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants