Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mikew910 14 posts 29 karma points
    Oct 24, 2009 @ 02:10
    mikew910
    0

    C# Class Library question

    Anyone know how I set the connection string from within a class library written in c#, at the moment I get a ArgumentNullExption parameter cannot be null: connection string. Can umbraco read this from anywhere besides web.config?

     

    thanks

    Mike

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Oct 24, 2009 @ 07:36
    Richard Soeteman
    0

    Hi Mike,

    What are you trying to do? Umbraco reads its connectionstring from the web.config. so if you want to change it change it there. Maybe if you give more info why you want to change the connectionstring people can help you.

    Cheers,

    Richard

  • anthony hall 222 posts 536 karma points
    Oct 24, 2009 @ 10:32
    anthony hall
    0

    have you added system.Configuration to your class library?

  • mikew910 14 posts 29 karma points
    Oct 24, 2009 @ 11:22
    mikew910
    0

    Hi Richard, many thanks for the reply - here's a bit of background of what im attempting. I have a series of methods in an asmx that basically correspond to different mime types eg. like an audio file (below). . the base methods all work fine from usercontrols i deploy - what i really want is to make a series of webmethods , so i can connect a rich client written in as3

    my custom webmethod   

        [WebMethod]
            public bool CreateAudioDocument(string caption, string body, string fileData)
            {
                byte[] content = Convert.FromBase64String(fileData);
                Orbitalmedia.CMS.api.documenttypes.Audio.CreateAudioDocument(caption, body, content);
                return true;     
            } 

    I looked into the source code of umbraco.business and found the area I might need to override but so far trying to setup VS to debug umbraco.business with my solution is challenging - the hope was to encapsulate the umbraco related function in the class lib and just import my class lib into the webservice

    from GlobalSettings in umbraco.business

           protected static void SaveSetting(string key, string value)
            {
                ExeConfigurationFileMap webConfig = new ExeConfigurationFileMap();
                webConfig.ExeConfigFilename = FullpathToRoot + "web.config";

                Configuration config =
                    ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
                config.AppSettings.Settings[key].Value = value;
                config.Save();
                ConfigurationManager.RefreshSection("appSettings");
            }

    any ideas appreciated

    cheers !

    Mike

  • mikew910 14 posts 29 karma points
    Oct 24, 2009 @ 12:09
    mikew910
    0

    Thanks Anthony yea done that.. its not a normal base class exception in c# - the issue i think is main how to supply whats required to umbraco outside of its appdomain. at the moment i just recieve connection string null - but a class library doesnt use a web.config but its own settings file..

     

    cheers

  • mikew910 14 posts 29 karma points
    Oct 26, 2009 @ 07:02
    mikew910
    0

    Maybe this can be done from the existing webservices in umbraco ? - only caveat I see is I'm uploading a file as a base64 encoded string through the webmethod - anyone have any experience uploading a file through the umbraco api or a better idea than what i've presented ?

    cheers

    Mike

Please Sign in or register to post replies

Write your reply to:

Draft