简体   繁体   中英

Using FreeSwitch Embedded, getting heap corruption error. No error targeting Framework 4.0, does happen with all later Framework

I have code that is working targeted to .NET Framework 4.0, which is no longer MS supported. You can not even install .NET Framework 4.0 SDK to newest versions of Visual Studio. I am attempting to update to a later framework, preferably 4.7.2 for widest compatibility, but 4.6.1 would be acceptable as I can at least have the SDK available in my IDE. Code compiles without any errors. 64 bit would be a nice bonus, but not a requirement.

The error happens at the first call to initialize the FreeSWITCH.Managed.dll as outlined here:

FreeSwitch embedded

Relevant code here:

            string err = "";
            const uint flags = (uint)(switch_core_flag_enum_t.SCF_USE_SQL | switch_core_flag_enum_t.SCF_USE_AUTO_NAT);
            freeswitch.switch_core_set_globals();
            try
            {
                freeswitch.switch_core_init(flags, switch_bool_t.SWITCH_FALSE, ref err);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception in switch_core_init "+ex.ToString());
            }

The program immediately crashes at the freeswitch.switch_core_init, no JIT error box. There is an option to debug on the test machine, and the error shown there is a heap corruption error. Presumably on the err string.

I see on this thread:

Prior post on subject

That some people have solved this problem, but as they didn't post HOW they solved it, I'm at a bit of a loss here. I've tried initializing a value to the string, including making it 500 million characters in size of spaces to no avail.

Actually got this working now.

The answer was fairly straight forward, I updated the DLL to the latest from FreeSwitch instead of trying to use the same ancient version the old .NET 4.0 code had been using.

The newer DLL will only run as 64 bit whereas the old ones would only run in 32 bit. So keeping an archive copy of the old programs for any 32 bit users will be necessary, but can finally get to actually updating the code now.

There is an MSI installer that has all the updated libraries linked from the FreeSwitch webpage for Windows installation.

FreeSwitch Windows Install Page

Do Note: With the updated DLL, all the ref keyword on calls to the FreeSwitch libraries will need to be changed to out keyword.

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