简体   繁体   中英

C# WPF Application go haywire in Release Mode but not Debug Mode

From my understanding, if not mistaken, release mode should compile with more optimization and hence the size is smaller.

I'm developing a WPF C# application, when I select Release mode , my application goes haywired but it works fine in Debug mode . May I know is it even possible? What is the most common factor for this to happen?

Update:
By right when the application load, landing page after login will display information that retrieved from database. When in debug mode , the information does show as expected. But in Release mode , the information does not show .

There is no problem in Database connection because if there is, user wouldn't be able to login at all.

I'm sorry that I couldn't share any codes as the project is way too huge. I'm expecting more on a general understanding between a Release mode and Debug mode and to find out the possible cause of the situation I'm facing. Any helps would be very much appreciated.

The biggesdt problem here is that Debug and Release are just placeholders for a particular configuration within your projects. You can actually change what they mean project by project.

By default however the differences are actually fairly small. 左侧调试,右侧发布 Click for large image

What this means is that you can use the configuration manager (Right click Solution in the Solution Explorer) to take your Debug configuration, and create a new one based on it, and slowly change these properties over so you can find what the problem actually is.

One commonly misunderstood trick is that you can still Debug a release assembly (even after its been optimized). So you should be able to get a far better understanding of what is going on, and then ask your question again.

If you use MVVM Light there are two differents mode:

    static ViewModelLocator()
    {
        ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

        if (ViewModelBase.IsInDesignModeStatic)
        {
            SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
        }
        else
        {
            SimpleIoc.Default.Register<IDataService, DataService>();
        }

        SimpleIoc.Default.Register<MainWindowViewModel>();
    }

SimpleIoc.Default.Register fails at IsInDesignModeStatic if the Interface is in different assembly - there are many problems. It is not enough data to solve this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM