belltric belltric - 2 months ago 5x Question

Conversion from string "~/app.config" to type 'Integer' is not valid

In web service Gloval.asax, i put log4net.Config.XmlConfigurator.Configure(New FileInfo(Server.MapPath("~/Web.config"))) in Application_Start.
Now, I have a console application. I'm try to put log4net.Config.XmlConfigurator.Configure(New FileInfo(AppDomain.CurrentDomain.BaseDirectory("~/app.config")))
and i get Conversion from string "~/app.config" to type 'Integer' is not valid. Whats causes this?


Turn option strict on and you'll see the error at compile time.

AppDomain.CurrentDomain.BaseDirectory is a string. When you reference something in brackets after that it's expecting a character index, which obviously "~/app.config" isn't.

Try AppDomain.CurrentDomain.BaseDirectory & "/app.config" instead.