jakubgarfield / Bonobo-Git-Server

Bonobo Git Server for Windows is a web application you can install on your IIS and easily manage and connect to your git repositories. Go to homepage for release and more info.
http://bonobogitserver.com
MIT License
1.81k stars 603 forks source link

#785 Fix exceptions at startup #786

Closed generik0 closed 6 years ago

generik0 commented 6 years ago

Fix exceptions at startup

generik0 commented 6 years ago

HI

I use OzCode, where you can enable clr exceptioons to break. And the changes i have made here are because excptions actually are being triggered at startup. So all your comments are corret, but these are things actually happening.

It is mostly because of this in global.asax at @line 183:

container.RegisterInstance(
                new GitServiceExecutorParams()
                {
                    GitPath = GetRootPath(ConfigurationManager.AppSettings["GitPath"]),
                    GitHomePath = GetRootPath(ConfigurationManager.AppSettings["GitHomePath"]),
                    RepositoriesDirPath = UserConfiguration.Current.Repositories,
                });

IoC is used but the static UserConfiguration.Current.Repositories is used before the initialize @lin 82

generik0 commented 6 years ago

I.e. "container.RegisterInstance(new GitServiceExecutorParam" calls before UserConfiguration.Current.Repositories is registered. This throws.

willdean commented 6 years ago

Sorry, I wasn't arguing that the exceptions were happening (you can see them in VS even without OzCode, actually).

I would like us to get the best possible fix for them, though - the best fix for a null reference exception is not always if(x != null) { ... } - it might be to find where the null is coming from.

Can you suggest a change to the initialisation order to prevent the UserConfiguration.Current problem?

generik0 commented 6 years ago

Yes it would 👍 The only thing is, i hope within a month or so to provide a feature. To change to autofac. Autofac is not my favourite IoC but, the code is easily portable. Making the Autofac become IoC will be the first step to a aspnetcore applicaiton.

Should we leave this merge for now, and fix the registration later?